mirror of https://github.com/opencv/opencv.git
parent
436d9bbcbb
commit
dc2bca0772
3 changed files with 59 additions and 8 deletions
@ -1,28 +1,33 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<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:versionName="1.0"> |
||||
<uses-sdk android:minSdkVersion="9" /> |
||||
<application android:label="@string/app_name" |
||||
android:icon="@drawable/icon" |
||||
android:hasCode="false" android:debuggable="true"> |
||||
android:debuggable="true"> |
||||
|
||||
<activity android:name="CvNativeActivity" |
||||
android:label="@string/app_name" |
||||
android:configChanges="orientation|keyboardHidden"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
</activity> |
||||
<activity android:name="android.app.NativeActivity" |
||||
android:label="@string/app_name"> |
||||
<meta-data android:name="android.app.lib_name" |
||||
android:value="native_activity" /> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
</activity> |
||||
</application> |
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/> |
||||
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/> |
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> |
||||
<uses-feature android:name="android.hardware.camera.front" android:required="false"/> |
||||
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/> |
||||
|
||||
|
||||
</manifest> |
||||
|
@ -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…
Reference in new issue