well it happens either way: if I call or. I used a breakpoint right at the line and it bombs when the line gets executed so I know its that bitmap.
private BitmapDrawable staticBg; private Canvas staticGr; both throw the error staticBg.draw(g); OR g.drawBitmap(staticBg.getBitmap(),0, 0, null); anymore ideas? Its really annoying. what makes it be recycled. even if it was another bitmap, i do not call recycle on any of my bitmaps so that means the GC has to get to them which makes no sense since I still have references to the object it should not get them. On Mar 7, 11:37 am, Marco Nelissen <marc...@android.com> wrote: > On Fri, Mar 6, 2009 at 5:59 AM, William <william.caine...@gmail.com> wrote: > > > I am drawing bitmaps left and right and I hit this issue where I > > create a bitmap in one section of my code and when I later try to draw > > on it using canvas, i get bitmap recycled. but I did not null if out, > > or call its recycle method. > > > Description: > > > I have a main Class that extends View that when first loads, initiates > > the main screen which loads/draws on bitmaps and no problem. I then > > added a key event that causes this screen to go away and load the next > > screen. The screen logic is encapsulated in a class that I already > > instantiated in the Main Class constructor and in my second screen its > > constructor is this code: > > > staticBg = new BitmapDrawable(Bitmap.createBitmap(320, 240, > > Bitmap.Config.RGB_565)); > > staticGr = new Canvas( staticBg.getBitmap() ); > > > at a later time, from my first screen when I push a button, i call my > > init() function that trys load screen two which does a draw to this > > bitmap and I get the following error: > > > 03-06 08:52:56.301: ERROR/AndroidRuntime(846): > > java.lang.NullPointerException > > 03-06 08:52:56.301: ERROR/AndroidRuntime(846): at > > android.graphics.Canvas.throwIfRecycled(Canvas.java:890) > > 03-06 08:52:56.301: ERROR/AndroidRuntime(846): at > > android.graphics.Canvas.drawBitmap(Canvas.java:911) > > > It is saying my bitmap is recycled BUT from what I understand that > > does not happened unless you explicitly call it or the garbage > > collector does when there are no more references to it BUT i obviously > > still have a reference to it. What am I doing wrong? > > Are you sure it's your bitmaps it's complaining about, and not some > other bitmap? > Are you using the drawing cache in any way? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---