title: App crashing with Intent MediaStore.ACTION_IMAGE_CAPTURE
body: <p>Im trying to pick an image from the camera but my app is crashing. Here is how Im doing it:</p>
  
  <pre><code>public void sendImageFromCamera (View v) {
      Uri fileUri;
      Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  
      // Creating file to save
      File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES), "PickImageSample");
  
      // Create app directory directory if it doesn't exists
      if (!mediaStorageDir.exists()){
          if (!mediaStorageDir.mkdirs()){
              Log.e("IMAGE FROM CAMERA", "failed to create directory");
          }
      }
  
      // Create file itself
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      File mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_"+ timeStamp + ".jpg");
  
  
      fileUri = Uri.fromFile(mediaFile);
  
      Log.d("FILE URI", fileUri.toString()); // Prints correctly the file path
  
      cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
  
      startActivityForResult(cameraIntent, 2);
  }
  
  @Override
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);
  
       if (requestCode == 2) { // Request from camera
           if (resultCode == RESULT_OK) {
               Toast.makeText(this, "Image saved to:\n" +
                       data.getData(), Toast.LENGTH_LONG).show();
           }
       }
   }
  </code></pre>
  
  <p>I've done it following the Android Guide: <a href="https://developer.android.com/guide/topics/media/camera.html" rel="nofollow">https://developer.android.com/guide/topics/media/camera.html</a></p>
  
  <p>My stack error is:</p>
  
  <pre><code>03-23 20:33:24.148: E/AndroidRuntime(30452): FATAL EXCEPTION: main
  03-23 20:33:24.148: E/AndroidRuntime(30452): Process: br.com.sampleApp.activities, PID:  30452
  03-23 20:33:24.148: E/AndroidRuntime(30452): java.lang.RuntimeException: Failure  delivering result ResultInfo{who=null, request=2, result=-1, data=null} to activity  {br.com.sampleApp.activities/br.com.sampleApp.activities.Chat}: java.lang.NullPointerException
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3446)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3489)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread.access$1300(ActivityThread.java:139)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.os.Handler.dispatchMessage(Handler.java:102)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.os.Looper.loop(Looper.java:136)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread.main(ActivityThread.java:5102)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at java.lang.reflect.Method.invoke(Method.java:515)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at dalvik.system.NativeStart.main(Native Method)
  03-23 20:33:24.148: E/AndroidRuntime(30452): Caused by: java.lang.NullPointerException
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at br.com.unichat.activities.Chat.onActivityResult(Chat.java:322)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.Activity.dispatchActivityResult(Activity.java:5446)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3442)
  03-23 20:33:24.148: E/AndroidRuntime(30452):    ... 11 more
  </code></pre>
  
  <p>For what I see the method is receiveng null information but I can't figure out why. Probably is something simple but it is already stuck in my head and I can't look at it in other way, can you guys help me out?</p>
  
  <p>Thanks in advance</p>