Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3275749/im-getting-a-nullpointerexception-when-i-use-action-image-capture-to-take-a-pict">I&#39;m getting a NullPointerException when I use ACTION_IMAGE_CAPTURE to take a picture</a>  </p>
</blockquote>



<p>I have some code.  </p>

<pre><code>Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(CamDir,  filename);
imageUri = Uri.fromFile(photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
startActivityForResult(intent, 0);


public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Bitmap bitmap = null;
    if (resultCode == Activity.RESULT_OK &amp;&amp; requestCode == 0) {
        Uri selectedImage = imageUri;
        ContentResolver cr = getContentResolver();
        bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImage);
    }
</code></pre>

<p>1.the phone in vertical position.<br>
2.start the application.<br>
3.press the button to take a photo.<br>
4.press Ok. (save photo)<br>
Everything fine.</p>

<p>1.the phone in vertical position.<br>
2.start the application.<br>
3.press the button to take a photo.<br>
4.rotate the phone to horizontal position.<br>
5.press Ok. (save photo)<br>
Have error  </p>

<pre><code>E/AndroidRuntime(22779): java.lang.RuntimeException: Failure delivering result
ResultInfo{who=null, request=0, result=-1, data=null} to activity 
com.photo/com.photo.PhotoActivity}:
java.lang.NullPointerException
</code></pre>

<p>I think when I rotate the phone to horizontal position intent was reloaded, and camera not<br>
know where to send results.<br>
How to fix this problem.</p>
