Fixed code block in android tutorial

This commit is contained in:
Andrey Kamaev 2012-07-03 12:02:58 +00:00
parent d386667478
commit 5615ec7c97

View File

@ -352,40 +352,40 @@ There is a very base code snippet for Async init. It shows only basis principles
public class MyActivity extends Activity implements HelperCallbackInterface public class MyActivity extends Activity implements HelperCallbackInterface
{ {
private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) { private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
@Override @Override
public void onManagerConnected(int status) { public void onManagerConnected(int status) {
switch (status) { switch (status) {
case LoaderCallbackInterface.SUCCESS: case LoaderCallbackInterface.SUCCESS:
{ {
Log.i(TAG, "OpenCV loaded successfully"); Log.i(TAG, "OpenCV loaded successfully");
// Create and set View // Create and set View
mView = new puzzle15View(mAppContext); mView = new puzzle15View(mAppContext);
setContentView(mView); setContentView(mView);
} break; } break;
default: default:
{ {
super.onManagerConnected(status); super.onManagerConnected(status);
} break; } break;
}
} }
}; }
};
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState)
{ {
Log.i(TAG, "onCreate"); Log.i(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.i(TAG, "Trying to load OpenCV library"); Log.i(TAG, "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
{ {
Log.e(TAG, "Cannot connect to OpenCV Manager"); Log.e(TAG, "Cannot connect to OpenCV Manager");
} }
} }
// ... // ...
} }
It this case application works with OpenCV Manager in asynchronous fashion. OnManagerConnected callback will be called in UI thread, when initialization finishes. It this case application works with OpenCV Manager in asynchronous fashion. OnManagerConnected callback will be called in UI thread, when initialization finishes.