Camera activity returning null android

Solution 1:

You are getting wrong because you are doing it wrong way.

If you pass the extra parameter MediaStore.EXTRA_OUTPUT with the camera intent then camera activity will write the captured image to that path and it will not return the bitmap in the onActivityResult method.

If you will check the path which you are passing then you will know that actually camera had write the captured file in that path.

For further information you can follow this, this and this

Solution 2:

I am doing it another way. The data.getData() field is not guaranteed to return a Uri, so I am checking if it's null or not, if it is then the image is in extras. So the code would be -

if(data.getData()==null){
    bitmap = (Bitmap)data.getExtras().get("data");
}else{
    bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData());
}

I am using this code in the production application, and it's working.

Solution 3:

I had a similar problem. I had commented out some lines in my manifest file which caused the thumbnail data to be returned as null.

You require the following to get this to work:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

I hope this resolves your issue

If you phone is a Samsung, it could be related to this http://kevinpotgieter.wordpress.com/2011/03/30/null-intent-passed-back-on-samsung-galaxy-tab/

There is another open question which may give additional information