I have method that returns Drawable, and if its Bitmap object is recycled then it reloads.
public Drawable getLogo() {
if(logo == null || Util.isRecycled(logo)) //Util.isRecycled checks - is Drawable's bitmap recycled, if it had so
logo = CacheController.getInstance().getLogo(this);
return logo;
}
But looks like right after calling bitmap.recycle() it’s bitmap.isRecycled() still returns false. Am I right, that bitmap recycle process goes asynchonously, or it’s just bug in my code? If so, how can I make sure, that Bitmap is not recycled right now?
If you are trying to implement some caching mechanism for bitmaps, you shouldn’t have to check if it’s recycled. Simply retrieve it from the cache and the cache will create it again if it doesn’t have a reference to it in it’s data structure. See this tutorial for how to cache bitmaps http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html