android - I'm getting a NullPointerException when I use ACTION_IMAGE_CAPTURE to take a picture -


I have a fairly simple app that launches the camera from a menu, the camera launches ok, but when I get a picture If I hit okay after taking it, then I get an NPE on my Nexus:

  E / Android Retentmann (3891): java.lang.RuntimeException: Results ResultInfo {which {Net.asplode.tr/net.asplode.tr.PostImage}: java.lang.NullPointerException E / AndroidRuntime (3891) for Android: = zero, request = 0, activity = 1, data = zero} activity: .app on Android .ActivityThread.deliverResults (ActivityThread.java:3515) E / AndroidRuntime (3891): On android.app.ActivityThread.handleSendResult (ActivityThread.java:3557) E / AndroidRuntime (3891): $ 2800 (ActivityThread.java on android.app.ActivityThread.access 125) e / AndroidRuntime (3891): on android.app.ActivityThread $ H.handleMessage (ActivityThread.java:2063) e / AndroidRuntime (3891): (handler android.os.Handler.dispatchMessage. Java: 99) e / AndroidRuntime (3891): at android.os.Looper.loop (Looper.java:123) E / AndroidRuntime (3891): android.app.ActivityThread.main (at ActivityThread.java:4627) E / AndroidRuntime (38 9 1 ): But Java.lang.reflect.Method.invokeNative (Native Method) E / AndroidRuntime (38 9 1): at java.lang.reflect.Method.invoke (method. Java 121) E / Android Rentaim (38 9 1): .os.ZygoteInit on com.android.internal $ MethodAndArgsCaller.run (ZygoteInit.java:868) E / AndroidRuntime (3891): com.android.internal.os.ZygoteInit .main (ZygoteInit.java:626) e / AndroidRuntime (3891): .system.NativeStart.main (Native method Dalvik) e / AndroidRuntime (3891): JavaklangkNullPointerException e / AndroidRuntime (3891): the net.asplode.tr.PostImage.onActivityResult due at (PostImage.java:92) e / AndroidRuntime (3891): on android.app.Activity.dispatchActivityResult (Activity.java:3890) e / AndroidRuntime (3891): Android on .app.ActivityThread.deliverResults (ActivityThread.java:3511) e / AndroidRuntime (3891): ... 11 more W / activity Manager (85): Force Finishing activity net.asplode.tr/.PostImage  < / Pre> 

code:

  @Override public booleanon option item selected (menu items) {if (ITE M.getItemId () == R. D. M.N.U.U. KAMERA) {Intent CameraIntent = New Intent (MediaStore.action_IMUNCente); Material values ​​= new material value (); Values.put (Media.TITLE, "Image"); URI tempPhotoUri = getContentResolver (). Insert (Media.EXTERNAL_CONTENT_URI, value); Camera element Input extras (mediastore.xtra_uuputup, tempfotourhi); StartActivityForResult (camera entrant, FROM_CAMERA); Back true; } @ Override Safe Wide Activity Results (Int avenue code, int result result, intent data) {if (resultCode! = RESULT_OK) {return; } URI Image URI = Data. GetData (); Log.i ("imageUri:", imageUri.toString ()); } 

Share exits the camera application EXTRA_OUTPUT, which is why the zero . However, some camera apps (like the hero) do very well. Then specify the answer to EXTRA_OUTPUT Nexus One Camera app will save the image at that location. After that on-activative result () check whether the intention is zero. If it is not, then use data.getData (), and if it uses the specific location in the EXTRA_OUTPUT by the stationary location and Urgh is inserted in Mediastore.


Comments