3

When I don't need Bitmaps anymore, I usally recycle them by calling

bitmap.recycle()

However, there are a couple of situations in which I need to use the recycled Bitmap again, so usually I 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 recycled and therefore could not be drawn. Does anyone have an idea what could cause this and how to fix it?

vauge
  • 801
  • 4
  • 14
  • 30
  • just an idea: maybe some manufacturer is caching Bitmaps internally. You may get the same recycled instance than before... To confirm that you could watch at the memory-location which you can get by `Bitmap.toString()` and see if it is the same than from that you recycled. – Rafael T Feb 05 '13 at 12:13
  • could you please tell me the android version for both phones? – Blackbelt Feb 05 '13 at 12:15
  • Both have android version 4.1 (but the one on which my code doesn't work is not a real phone, it's a virtual device!) Edit: If that should be important, the virtual device is a Galaxy S2... – vauge Feb 05 '13 at 12:19

0 Answers0