add this to your manifest for list activity.
android:configChanges="orientation|keyboardHidden"
If this does not help, add this code snippet for your image file to try the bitmap
private Bitmap decodeFile(File f){ FileOutputStream os = null; try { //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; FileInputStream fis = new FileInputStream(f); BitmapFactory.decodeStream(fis, null, o); fis.close(); int scale = 1; if (o.outHeight > IMAGE_MAX_SIZE || o.outWidth > IMAGE_MAX_SIZE) { scale = (int)Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5))); } //Decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; fis = new FileInputStream(f); try { b = BitmapFactory.decodeStream(fis, null, o2); } catch (OutOfMemoryError e) { Log.d("hai","filename"+f); System.gc(); } fis.close(); } catch (IOException e) { } return b; }
Download a lot of images, because of which the application stops working with memory and blocks closing. I think this is what happens with your application. The memory issue is a complex android issue when developing an application. This can be resolved by manually clearing unused bitmaps and using the garbage collector.
Try using System.gc ();
Try reusing the bitmap using
Bitmap.recycle ();
Make all unused bitmaps null.
Discard all unused memory.
This will help you a lot and also check out this link. Use a memory analyzer, this will help you determine the freed memory> try this link
source share