title: How to get path of picture in onActivityresult (Intent data is null)
body: <p>I have to launch the camera, and when the users has done the picture, I have to take it and show it in a view.</p>
  
  <p>Looking at <a href="http://developer.android.com/guide/topics/media/camera.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/media/camera.html</a> I have done:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          bLaunchCamera = (Button) findViewById(R.id.launchCamera);
          bLaunchCamera.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Log.d(TAG, "lanzando camara");
  
                  //create intent to launch camera
                  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  
                  imageUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); //create a file to save the image
                  intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); //set the image file name
  
                  //start camera
                  startActivityForResult(intent, CAMERA_REQUEST);
              }
          });
  
  /**
       * Create a File Uri for saving image (can be sued to save video to)
       **/
      private Uri getOutputMediaFileUri(int mediaTypeImage) {
          return Uri.fromFile(getOutputMediaFile(mediaTypeImage));
      }
  
      /**
       * Create a File  for saving image (can be sued to save video to)
       **/
      private File getOutputMediaFile(int mediaType) {
          //To be safe, is necessary to check if SDCard is mounted
  
          File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                  (String) getResources().getText(R.string.app_name));
  
          //create the storage directory if it does not exist
          if (!mediaStorageDir.exists()) {
              if (!mediaStorageDir.mkdirs()) {
                  Log.d(TAG, "failed to create directory");
                  return null;
              }
          }
  
          //Create a media file name
  
          String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmmss").format(new Date());
          File mediaFile;
  
          if (mediaType == MEDIA_TYPE_IMAGE) {
              mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
  
          } else {
              return null;
          }
          return mediaFile;
      }
  
  @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          if(requestCode == CAMERA_REQUEST) {
              if(resultCode == RESULT_OK) {
                  //Image captured and saved to fileUri specified in Intent
                  Toast.makeText(this, "image saved to:\n" + data.getData(), Toast.LENGTH_LONG).show();
                  Log.d(TAG, "lanzando camara");
              } else if(resultCode == RESULT_CANCELED) {
                  //user cancelled the image capture;
                  Log.d(TAG, "usuario a cancelado la captura");
              } else {
                  //image capture failed, advise user;
                  Log.d(TAG, "algo a fallado");
              }
          }
      }
  </code></pre>
  
  <p>When the picture has been done, the app crashes when it try to send the 'Toast' info because 'data' is null. </p>
  
  <p>But if I debug the app I can see that the image has been saved.</p>
  
  <p><a href="https://i.stack.imgur.com/LRONI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LRONI.jpg" alt="enter image description here"></a></p>
  
  <p>So my question is: How can I get the path in the onActivityResult?</p>