title: Taking photo android
body: <p>I'm having some problem in my android application when I try to take a picture and get it from onActivityResult(). I wanted to be sure that the code will work so I have just copied the exact code of this page <a href="http://developer.android.com/training/camera/photobasics.html" rel="nofollow">http://developer.android.com/training/camera/photobasics.html</a>.</p>
  
  <p>So these are the methods I used; I call dispatchTakePictureIntent() when the user click on a button.`</p>
  
  <pre><code>private File createImageFile() throws IOException {
      // Create an image file name
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      String imageFileName = "JPEG_" + timeStamp + "_";
      File storageDir = Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES);
      File image = File.createTempFile(
          imageFileName,  /* prefix */
          ".jpg",         /* suffix */
          storageDir      /* directory */
      );
  
      // Save a file: path for use with ACTION_VIEW intents
      mCurrentPhotoPath = "file:" + image.getAbsolutePath();
      return image;
  }
  
  private void dispatchTakePictureIntent() {
      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      // Ensure that there's a camera activity to handle the intent
      if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
          // Create the File where the photo should go
          File photoFile = null;
          try {
              photoFile = createImageFile();
          } catch (IOException ex) {
  
          }
          // Continue only if the File was successfully created
          if (photoFile != null) {
              takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                      Uri.fromFile(photoFile));
              startActivityForResult(takePictureIntent, 15);
          }
      }
  }` 
  </code></pre>
  
  <p>The problem is that when the onActivityResult() method is called, I get the right requestCode, the right resultCode but the third parameter is null. I want to get the image Bitmap or Path, but I can't without it. Why does this happen? Is it because this code isn't supposed to return that parameter? In that case, how should I modify it? </p>