In my application, I use the camera of an Android device to capture an image. In some device it works fine, but not all, I just tested it LG nexus 5 E960, after I captured the image, it always fails without saving the result, this is my code:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, 1); protected void onActivityResult(int requestCode, int resultCode, Intent returnimage) { super.onActivityResult(requestCode, resultCode, returnimage); switch (requestCode) { case 1: if (resultCode == RESULT_OK) { Uri selectedImage = returnimage.getData(); String stringUri; stringUri = selectedImage.toString(); Intent i1 = new Intent(MainActivity.this, Secondpage.class); i1.putExtra("Stringuri",stringUri ); startActivity(i1); } break;
And my logarithm is:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.photostikers/com.photostikers.MainActivity}: java.lang.NullPointerException 02-13 12:27:54.315: E/AndroidRuntime(28759): at android.app.ActivityThread.deliverResults(ActivityThread.java:3365) 02-13 12:27:54.315: E/AndroidRuntime(28759): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2775) 02-13 12:27:54.315: E/AndroidRuntime(28759): ... 12 more 02-13 12:27:54.315: E/AndroidRuntime(28759): Caused by: java.lang.NullPointerException 02-13 12:27:54.315: E/AndroidRuntime(28759): at com.photostikers.MainActivity.onActivityResult(MainActivity.java:335) 02-13 12:27:54.315: E/AndroidRuntime(28759): at android.app.Activity.dispatchActivityResult(Activity.java:5423) 02-13 12:27:54.315: E/AndroidRuntime(28759): at android.app.ActivityThread.deliverResults(ActivityThread.java:3361) 02-13 12:27:54.315: E/AndroidRuntime(28759): ... 13 more
android
Nirmal singh
source share