Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to Load More then 20mb Image in Imageview

My project is about image processing in Android. My problem is that when I load a 22MB image in an ImageView I get an OutOfMemoryError.

Error:

java.lang.OutOfMemoryError: Failed to allocate a 244588824 byte allocation with 11397108 free bytes and 79MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method)

like image 202
Ricky Patel Avatar asked Nov 10 '22 01:11

Ricky Patel


1 Answers

You need resize your image and load subsample to imageview: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

You can use some lib as Picaso, Glide to do that.

like image 163
mdtuyen Avatar answered Nov 14 '22 21:11

mdtuyen