The code below would fix an issue where a bitmap would have been recycled twice. This would not fix the issue where a bitmap would have been recycled where it should have never been recycled at all.
BTW: the boolean expression (bitmap1 != bitmap2) or (bitmap1 == bitmap2) is very fast. It is just comparing two 32-bit values. On Monday, July 16, 2012 6:16:17 AM UTC-4, Fran wrote: > > I have had the same problem with some devices, but I did not study the > case in deep, just applied this workaround directly: > > if ( ! oldBitmap.isRecycled()) > oldBitmap.recycle(); > > It may be faster than comparing one bitmap to another, but to be honest > I did not try the other method. > > Regards, > > > On 13/07/12 15:42, Craigo wrote: > > Hi Google, > > > > My app that has been running for over 2 years without an update, finally > > broke with Jelly Bean. The error: "Sorry, an error has occurred: bitmap > is > > recycled". > > > > The problem was with calling recycle on a bitmap: > > > > Bitmap bitmapOld = bitmap; > > bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false); > > bitmapOld.recycle(); > > > > Note: I never referenced bitmapOld again. > > > > The fix was easy, I just don't recycle any more. However, it seems odd > > that this would have broken. Maybe creating the scaled bitmap shares > > memory with the unscaled bitmap? > > > > Anyway, hopefully this information is useful to someone. > > > > Cheers, and keep up the excellent work! > > > > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

