I am getting image from assets and assigning to imageView, everything works fine but when I see heap memory size it keeps on growing when I load the same page again and again, Below is the code what I am using to get Image from assets folder.
private Bitmap getBitmapFromAsset(String strName) throws IOException
{
AssetManager assetManager = getAssets();
InputStream istr = assetManager.open(strName);
Bitmap bitmap = BitmapFactory.decodeStream(istr);
return bitmap;
}
//Code to assign bitmap to imageview
ImageView itemImage = (ImageView) findViewById(R.id.itemImage);
try {
Bitmap bm = getBitmapFromAsset("full/" + Uri.parse(menuItem.getFullImage()).getLastPathSegment());
itemImage.setImageBitmap(bm);
} catch (IOException e) {
e.printStackTrace();
}
This is all what I am doing, is there any where I need to recycle the bitmap?
Actually I am using a parent activity which is extended by all activities and that activity is registered with LocationListener, so LocationListener is preventing the activity from destroying.