Bitmap memory acceleration for Android, what to do more

I am creating an application in which you have a function to download a message with an image. When a user selects an image, I show a thumbnail, but when I change the screen orientation, I get a memory leak. I managed to bring it to such an extent that it takes about 25 orientation changes in the memory leaks, but can I completely avoid this?

This is the code I'm using for a bitmap,

private ImageView miniPicture;
private String imagePath;
private WeakReference<Bitmap> imageBitmap;

....

BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
imageBitmap = new WeakReference<Bitmap>(BitmapFactory.decodeFile(imagePath, options));                
miniPicture.setImageBitmap(imageBitmap.get());
+1
source share

All Articles