1 *********************************************
2 Base Loader Callback Interface Implementation
3 *********************************************
6 .. class:: BaseLoaderCallback
8 Basic implementation of ``LoaderCallbackInterface``. Logic of this implementation is
9 well-described by the following scheme:
11 .. image:: img/AndroidAppUsageModel.png
13 Using in Java Activity
14 ----------------------
16 There is a very base code snippet implementing the async initialization with ``BaseLoaderCallback``.
17 See the "15-puzzle" OpenCV sample for details.
22 public class MyActivity extends Activity implements HelperCallbackInterface
24 private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
26 public void onManagerConnected(int status) {
28 case LoaderCallbackInterface.SUCCESS:
30 Log.i(TAG, "OpenCV loaded successfully");
31 // Create and set View
32 mView = new puzzle15View(mAppContext);
33 setContentView(mView);
37 super.onManagerConnected(status);
43 /** Call on every application resume **/
45 protected void onResume()
47 Log.i(TAG, "Called onResume");
50 Log.i(TAG, "Trying to load OpenCV library");
51 if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, this, mOpenCVCallBack))
53 Log.e(TAG, "Cannot connect to OpenCV Manager");
60 Default ``BaseLoaderCallback`` implementation treats application context as ``Activity`` and calls
61 ``Activity.finish()`` method to exit in case of initialization failure.
62 To override this behavior you need to override ``finish()`` method of ``BaseLoaderCallback`` class
63 and implement your own finalization method.