Reputation: 3
I am facing outofmemory while trying to load bitmap image from Assest, Below is my code:
AssetManager assetManager = context.getAssets();
InputStream istr = assetManager.open(FILE_NAME);
bitmap = BitmapFactory.decodeStream(istr);
I am getting below exception most of time I am loading the image:
ERROR/AndroidRuntime(731): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
I have gone throw few articles on managing image size in ImageView. But my code not reaching to that point even.
Please Help
Upvotes: 0
Views: 79
Reputation: 4382
Just add following code to your manifest
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme" />
Upvotes: 0
Reputation: 13101
I guess the resolution is very big.
You should read the size first, and scale it before load it to the memory.
the best practice for this
Loading Large Bitmaps Efficiently
Upvotes: 2