How to avoid a Bitmap to be recycled?

Problems with Canvas, OpenGL, etc...

How to avoid a Bitmap to be recycled?

Postby gskbyte » Mon Jun 28, 2010 10:26 pm


I'm writing a small app in which I load a sample Bitmap and modify it several times. Each modification is saved inside a static Vector<Bitmap>. The problem is that when I call canvas.drawBitmap(mBitmaps.get(i));, it throws a NullPointerException because the bitmaps are recycled.

Is it possible to avoid the bitmaps to be automatically recycled?

Thank you!
Experienced Developer
Experienced Developer
Posts: 52
Joined: Tue Jan 12, 2010 1:51 pm


Re: How to avoid a Bitmap to be recycled?

Postby Zael » Thu Oct 07, 2010 6:56 pm

I am having a similar problem with Bitmaps in an array. They load fine (BitmapFactory doesn't return null), but later when I try to use them, I find that several have become null (recycled), while others are still available. I am fairly certain I am not setting any bitmaps to null myself. Did you, gskbyte, or anybody else ever figure out a solution to this problem?

Posts: 5
Joined: Tue Oct 05, 2010 8:43 pm


Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests