I have an app published and one of the fundamental features is to allow the user to take a picture, and then save that photo in a specific folder on their External Storage.
I suspect 3 posible problems may have created your issue:
Some devices return null
when you call extras.get("data");
in onActivityResult
method so your problem may be a NullPointerException
. To solve this, you need to pass the exact URI
location to tell the camera app where you want it to store and use it in onActivityResult
to retrieve the image as a Bitmap
.
Some other devices return a full size Bitmap
when extras.get("data");
in onActivityResult
. If the bitmap is too large that can result in an OutOfMemmoryError
, so maybe you need to decode your image in a smaller size to not take so much memmory heap. This two links can help you in this situation:
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
BitmapFactory OOM driving me nuts
Maybe your activity is destroyed by the GC
so you have to use onSavedInstanceState
and onRestoreInstanceState
to save your Activity
's data. See the answer of this previous post for more information.
I don't know if you already have dealt with these issues.
Hope that helps:)