Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to resume activity in random order
    text
    copied!<p>Android Platform 4.0.4 Opencv 2.4.3</p> <p>I am trying to get a snapshot from camera and then processing it using opencv! but SOMETIMES (in random order) I am getting the following Exception </p> <pre><code>12-19 18:54:33.659: E/AndroidRuntime(16625): FATAL EXCEPTION: main 12-19 18:54:33.659: E/AndroidRuntime(16625): java.lang.RuntimeException: Unable to resume activity {com.example.superemr/com.example.superemr.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=11, result=-1, data=Intent { act=inline-data dat=file:///mnt/sdcard/Pictures/IDSMART/IDS-1607435583.jpg typ=image/jpeg (has extras) }} to activity {com.example.superemr/com.example.superemr.MainActivity}: java.lang.NullPointerException 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2464) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2492) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1997) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3371) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.access$700(ActivityThread.java:127) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.os.Handler.dispatchMessage(Handler.java:99) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.os.Looper.loop(Looper.java:137) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.main(ActivityThread.java:4441) 12-19 18:54:33.659: E/AndroidRuntime(16625): at java.lang.reflect.Method.invokeNative(Native Method) 12-19 18:54:33.659: E/AndroidRuntime(16625): at java.lang.reflect.Method.invoke(Method.java:511) 12-19 18:54:33.659: E/AndroidRuntime(16625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 12-19 18:54:33.659: E/AndroidRuntime(16625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 12-19 18:54:33.659: E/AndroidRuntime(16625): at dalvik.system.NativeStart.main(Native Method) 12-19 18:54:33.659: E/AndroidRuntime(16625): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=11, result=-1, data=Intent { act=inline-data dat=file:///mnt/sdcard/Pictures/IDSMART/IDS-1607435583.jpg typ=image/jpeg (has extras) }} to activity {com.example.superemr/com.example.superemr.MainActivity}: java.lang.NullPointerException 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.deliverResults(ActivityThread.java:3000) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2451) 12-19 18:54:33.659: E/AndroidRuntime(16625): ... 13 more 12-19 18:54:33.659: E/AndroidRuntime(16625): Caused by: java.lang.NullPointerException 12-19 18:54:33.659: E/AndroidRuntime(16625): at com.example.superemr.MainActivity.onActivityResult(MainActivity.java:88) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.Activity.dispatchActivityResult(Activity.java:4649) 12-19 18:54:33.659: E/AndroidRuntime(16625): at android.app.ActivityThread.deliverResults(ActivityThread.java:2996) 12-19 18:54:33.659: E/AndroidRuntime(16625): ... 14 more </code></pre> <p>when i try to debug the problem usually the program succeed but sometimes and before the onResume get called an exception is thrown ! </p> <pre><code>public void onResume() { super.onResume(); if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback)) Toast.makeText(this, "cannot connect to opencv ",Toast.LENGTH_SHORT).show(); } public void cap(View view) { Intent camInt = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List&lt;ResolveInfo&gt; aa = getPackageManager().queryIntentActivities( camInt, PackageManager.MATCH_DEFAULT_ONLY); if (aa != null &amp;&amp; aa.size() &gt; 0) { File dir = new File( android.os.Environment .getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_PICTURES), "IDSMART"); if (!dir.exists()) { boolean result = dir.mkdirs(); Log.d("Creating Dirs Result:", result ? "Create have been Done :)" : "Create have not been done :("); } Random r = new Random(); file = new File(dir, String.format("IDS%s.jpg", r.nextInt())); camInt.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); startActivityForResult(camInt, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload