I'm tring to get image from gallery (by intent).
I got this error:
985120-byte external allocation too large for this process.
Out of memory: Heap Size=4871KB, Allocated=2472KB, Bitmap Size=19677KB
VM won't let us allocate 985120 bytes
That's my code where I get image:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
....
mBitmap = Media.getBitmap(this.getContentResolver(), data.getData());
...
}
How can i solve it ?
-------- UPDATE ---------
I noticed that if I select a pre-existent image (HTC photo installed) I get this error. If I select image picked from camera all works fine.
So, I change my code according to this http://developer.android.com/training/displaying-bitmaps/load-bitmap.html:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
InputStream stream = getContentResolver().openInputStream(data.getData());
mBitmap = BitmapFactory.decodeStream(stream,null,options);
stream.close();
But now the bitmap is NULL !!!