Trouble working with the camera in onActivityResult

Solution 1:

Your Activity is probably being destroyed and re-created when the camera activity is going off. Maybe try saving photoPath into the Bundle in onSaveInstanceState and then fish it back out in onCreate (make sure to check for nulls in onCreate when you do so)?

Solution 2:

I can not using the data. But I think you need changed as follow

photo to become general variable.

intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));

So, you must be take it from this folder:

Bitmap photo = Media.getBitmap(getContentResolver(), Uri.fromFile(photo) );

I follow your code and change.