mirror of https://github.com/opencv/opencv.git
Android samples are updated: onPause()/onResume() release/open camera, a message is shown on camera open error, minor fixes in code and resources
parent
0ba3236ce0
commit
5855c4905e
31 changed files with 820 additions and 427 deletions
@ -1,4 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">Tutorial 1 Basic - 0. Android Camera</string> |
||||
<string name="app_name">Tutorial 0 (Basic) - Android Camera</string> |
||||
</resources> |
||||
|
@ -1,4 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">Tutorial 1 Basic - 1. Add OpenCV</string> |
||||
<string name="app_name">Tutorial 1 (Basic) - Add OpenCV</string> |
||||
</resources> |
||||
|
@ -1,4 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">Tutorial 1 Basic - 2. Use OpenCV Camera</string> |
||||
<string name="app_name">Tutorial 2 (Basic) - Use OpenCV Camera</string> |
||||
</resources> |
||||
|
@ -1,4 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">Tutorial 2 Advanced - 1. Add Native OpenCV</string> |
||||
<string name="app_name">Tutorial 3 (Advanced) - Add Native OpenCV</string> |
||||
</resources> |
||||
|
@ -1,23 +1,52 @@ |
||||
package org.opencv.samples.tutorial3; |
||||
|
||||
import android.app.Activity; |
||||
import android.app.AlertDialog; |
||||
import android.content.DialogInterface; |
||||
import android.os.Bundle; |
||||
import android.util.Log; |
||||
import android.view.Window; |
||||
|
||||
public class Sample3Native extends Activity { |
||||
private static final String TAG = "Sample::Activity"; |
||||
private Sample3View mView; |
||||
|
||||
public Sample3Native() { |
||||
Log.i(TAG, "Instantiated new " + this.getClass()); |
||||
} |
||||
|
||||
@Override |
||||
protected void onPause() { |
||||
Log.i(TAG, "onPause"); |
||||
super.onPause(); |
||||
mView.releaseCamera(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onResume() { |
||||
Log.i(TAG, "onResume"); |
||||
super.onResume(); |
||||
if( !mView.openCamera() ) { |
||||
AlertDialog ad = new AlertDialog.Builder(this).create(); |
||||
ad.setCancelable(false); // This blocks the 'BACK' button
|
||||
ad.setMessage("Fatal error: can't open camera!"); |
||||
ad.setButton("OK", new DialogInterface.OnClickListener() { |
||||
public void onClick(DialogInterface dialog, int which) { |
||||
dialog.dismiss(); |
||||
finish(); |
||||
} |
||||
}); |
||||
ad.show(); |
||||
} |
||||
} |
||||
|
||||
/** Called when the activity is first created. */ |
||||
@Override |
||||
public void onCreate(Bundle savedInstanceState) { |
||||
Log.i(TAG, "onCreate"); |
||||
super.onCreate(savedInstanceState); |
||||
requestWindowFeature(Window.FEATURE_NO_TITLE); |
||||
setContentView(new Sample3View(this)); |
||||
mView = new Sample3View(this); |
||||
setContentView(mView); |
||||
} |
||||
} |
||||
|
@ -1,4 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">Tutorial 2 Advanced - 2. Mix Java+Native OpenCV</string> |
||||
<string name="app_name">Tutorial 4 (Advanced) - Mix Java+Native OpenCV</string> |
||||
</resources> |
||||
|
Loading…
Reference in new issue