Android - How to upload over 20 MB images to Imageview

My project is dedicated to image processing in Android. My problem is that when I load 22 MB of image into ImageView, I get OutOfMemoryError.

Error:

java.lang.OutOfMemoryError: failed to allocate 244588824 bytes with 11397108 free bytes and 79 MB until OOM dalvik.system.VMRuntime.newNonMovableArray (native method)

+5
source share
2 answers

You need to resize the image and load the subquery into the image: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

You can use some lib like Picaso, Glide for this.

0
source

Add this to the manifest file:

<application ... android:largeHeap="true" ... > </application> 
-1
source

Source: https://habr.com/ru/post/1236670/


All Articles