After I've used a MediaStore.ACTION_IMAGE_CAPTURE intent to take a
photo, when I try to retrieve the captured image, I sometimes get an
out of memory error as shown below. The odd thing is the huge size
of the memory trying to be allocated is always reported as 10,077,696
(x99c600). However, the image file is much smaller, typically around
750,000 bytes. Any suggestions on how to get around this problem?
I'm testing this on a Nexus One with firmware version: 2.1-update1
and Build number: ERE27.
----- logcat output --------------------
D/photo ( 5562): photoUri=content://media/external/images/media/32
E/dalvikvm-heap( 5562): 10077696-byte external allocation too large
for this process.
E/ ( 5562): VM won't let us allocate 10077696 bytes
D/skia ( 5562): --- decoder->decode returned false
W/System.err( 5562): java.lang.OutOfMemoryError: bitmap size exceeds
VM budget
W/System.err( 5562): at
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
W/System.err( 5562): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
W/System.err( 5562): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:515)
W/System.err( 5562): at android.provider.MediaStore$Images
$Media.getBitmap(MediaStore.java:475)
---- code used to start the camera -----------------------
Intent photoPickerIntent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
Uri photoUri = getNewTempPhotoUri();
photoPickerIntent.putExtra( MediaStore.EXTRA_OUTPUT,
photoUri );
photoPickerIntent.putExtra( MediaStore.EXTRA_VIDEO_QUALITY,
"0") ; // 0= low quality suitable for MMS
photoPickerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivityForResult(photoPickerIntent,
WimgoApplication.ADD_PHOTO );
private Uri getNewTempPhotoUri() {
ContentValues values = new ContentValues();
values.put(Media.TITLE, "a title");
values.put(Media.DESCRIPTION, "a description");
tempPhotoUri = null;
try {
tempPhotoUri =
getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
} catch(UnsupportedOperationException e){
try{
tempPhotoUri =
getContentResolver().insert(Media.INTERNAL_CONTENT_URI, values);
}catch(UnsupportedOperationException e2){
e2.printStackTrace();
}
}
return tempPhotoUri ;
}
----- code called from my onActivityResult method used to retrieve
the image --------------------
Bitmap bitmap =
MediaStore.Images.Media.getBitmap(getContentResolver(),
tempPhotoUri );
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en