title: Take a photo with the standard android app and store in db
body: <p>In my android application I need to call the standard photo app, take a photo and store it in the sqlite database the device.</p>
  
  <p>This is my handler for the button to start the intent</p>
  
  <pre><code>private Uri fileUri;
  private File file;
  private ImageView foto;
  
  public void fotoHandler(View view) {
      // create Intent to take a picture and return control to the calling application
      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  
      file = FileUtilities.getOutputMediaFile();
      fileUri = Uri.fromFile(file); // create a file to save the image
      intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
  
      // start the image capture Intent
      startActivityForResult(intent, TAKE_PICTURE);
  }
  </code></pre>
  
  <p>This is the resulthandler</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (resultCode == RESULT_OK) {
          // Image captured and saved to fileUri specified in the Intent
          Toast.makeText(this, "Image saved to:\n" +
                           fileUri.toString(), Toast.LENGTH_LONG).show();
  
           try {
               Bitmap bitmap =  MediaStore.Images.Media.getBitmap(this.getContentResolver(), fileUri);
               file.delete();
               foto.setImageBitmap(laatsteFoto);
           } catch (FileNotFoundException e) {
               Toast.makeText(this, "File " + fileUri.toString() + " can't be found !", Toast.LENGTH_LONG).show();
           } catch (IOException e) {
               Toast.makeText(this, "File " + fileUri.toString() + " can't be read !", Toast.LENGTH_LONG).show();
           }
       } else if (resultCode == RESULT_CANCELED) {
           // User cancelled the image capture
       } else 
           Toast.makeText(this, "Error during retrieving photo from camera !", Toast.LENGTH_LONG).show();
       }
  }
  </code></pre>
  
  <p>It works fine on my Acer A100 with ICS, but gives problems on my Samsung Galaxy S2 with ICS.</p>
  
  <pre><code>10-24 08:44:05.190: E/AndroidRuntime(19861): FATAL EXCEPTION: main
  10-24 08:44:05.190: E/AndroidRuntime(19861): java.lang.RuntimeException: Unable to resume activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.NullPointerException
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2455)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2483)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1997)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3362)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.access$700(ActivityThread.java:127)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.os.Handler.dispatchMessage(Handler.java:99)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.os.Looper.loop(Looper.java:137)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.main(ActivityThread.java:4511)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at java.lang.reflect.Method.invoke(Method.java:511)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at dalvik.system.NativeStart.main(Native Method)
  10-24 08:44:05.190: E/AndroidRuntime(19861): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.NullPointerException
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2991)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2442)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    ... 13 more
  10-24 08:44:05.190: E/AndroidRuntime(19861): Caused by: java.lang.NullPointerException
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at be.lengo.autikoken.IngredientWijzigen.onActivityResult(IngredientWijzigen.java:233)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.Activity.dispatchActivityResult(Activity.java:4654)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2987)
  10-24 08:44:05.190: E/AndroidRuntime(19861):    ... 14 more
  </code></pre>
  
  <p>Log when I comment the toast with the result</p>
  
  <pre><code>10-24 09:27:06.520: E/AndroidRuntime(21849): FATAL EXCEPTION: main
  10-24 09:27:06.520: E/AndroidRuntime(21849): java.lang.RuntimeException: Unable to resume activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.NullPointerException
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2455)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2483)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1997)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3362)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.access$700(ActivityThread.java:127)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.os.Handler.dispatchMessage(Handler.java:99)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.os.Looper.loop(Looper.java:137)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.main(ActivityThread.java:4511)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at java.lang.reflect.Method.invoke(Method.java:511)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at dalvik.system.NativeStart.main(Native Method)
  10-24 09:27:06.520: E/AndroidRuntime(21849): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {be.lengo.autikoken/be.lengo.autikoken.IngredientWijzigen}: java.lang.NullPointerException
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2991)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2442)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    ... 13 more
  10-24 09:27:06.520: E/AndroidRuntime(21849): Caused by: java.lang.NullPointerException
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.content.ContentResolver.openInputStream(ContentResolver.java:361)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:715)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at be.lengo.autikoken.IngredientWijzigen.onActivityResult(IngredientWijzigen.java:236)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.Activity.dispatchActivityResult(Activity.java:4654)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2987)
  10-24 09:27:06.520: E/AndroidRuntime(21849):    ... 14 more
  </code></pre>