Initialization with Manager instead static link added.
This commit is contained in:
parent
436d9bbcbb
commit
dc2bca0772
@ -1,21 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.opencv.examples.native_activity"
|
package="org.opencv.samples.NativeActivity"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<uses-sdk android:minSdkVersion="9" />
|
<uses-sdk android:minSdkVersion="9" />
|
||||||
<application android:label="@string/app_name"
|
<application android:label="@string/app_name"
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:hasCode="false" android:debuggable="true">
|
android:debuggable="true">
|
||||||
<activity android:name="android.app.NativeActivity"
|
|
||||||
android:label="@string/app_name">
|
<activity android:name="CvNativeActivity"
|
||||||
<meta-data android:name="android.app.lib_name"
|
android:label="@string/app_name"
|
||||||
android:value="native_activity" />
|
android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="@string/app_name">
|
||||||
|
<meta-data android:name="android.app.lib_name"
|
||||||
|
android:value="native_activity" />
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA"/>
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
include ../../sdk/native/jni/OpenCV.mk
|
||||||
|
|
||||||
LOCAL_MODULE := native_activity
|
LOCAL_MODULE := native_activity
|
||||||
LOCAL_SRC_FILES := native.cpp
|
LOCAL_SRC_FILES := native.cpp
|
||||||
LOCAL_LDLIBS := -lm -llog -landroid
|
LOCAL_LDLIBS := -lm -llog -landroid
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package org.opencv.samples.NativeActivity;
|
||||||
|
|
||||||
|
import org.opencv.android.BaseLoaderCallback;
|
||||||
|
import org.opencv.android.LoaderCallbackInterface;
|
||||||
|
import org.opencv.android.OpenCVLoader;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class CvNativeActivity extends Activity {
|
||||||
|
private static final String TAG = "OCVSample::Activity";
|
||||||
|
|
||||||
|
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
||||||
|
@Override
|
||||||
|
public void onManagerConnected(int status) {
|
||||||
|
switch (status) {
|
||||||
|
case LoaderCallbackInterface.SUCCESS:
|
||||||
|
{
|
||||||
|
Log.i(TAG, "OpenCV loaded successfully");
|
||||||
|
System.loadLibrary("native_activity");
|
||||||
|
Intent intent = new Intent(CvNativeActivity.this, android.app.NativeActivity.class);
|
||||||
|
CvNativeActivity.this.startActivity(intent);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
super.onManagerConnected(status);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public CvNativeActivity() {
|
||||||
|
Log.i(TAG, "Instantiated new " + this.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user