Android: how to reuse a recycled Bitmap?

When I no longer need bitmaps, I usually recycle them by calling

bitmap.recycle()

      

However, there are a few situations in which I need to use the recycled Bitmap again, so I usually just load it again:

if(bitmap.isRecylced()) bitmap = BitmapFactory.decodeResource(gv.getContext().getResources(),bmp);
Log.e("log","bitmap recycled? "+bitmap.isRecycled());

      

As I expected, bitmap.isRecycled () returned "false" on my phone, but when I tried to run the app on another phone, it returned "true", the Bitmap was still reworked and therefore could not be drawn. Does anyone have an idea what might be causing this and how to fix it?

+3


source to share





All Articles