Android bitmap recycling in widget -
a bitmap
on widget updates every second. after approximately 20 seconds exception:
java.lang.illegalargumentexception: remoteviews widget update exceeds maximum bitmap memory usage (used: 12572000, max: 12441600)
i think because there no bitmap
recycled ?
***edit***
i recycle bitmap mentioned in question / answer: redraw widget every second
however error occurs:
java.lang.illegalstateexception: can't parcel recycled bitmap
my updated code:
bitmap bitmap, lastbitmap; private static void updatetime(remoteviews views, context context, appwidgetmanager appwidgetmanager, int appwidgetid){ [...] bitmap = [...] //here create bitmap views.setimageviewbitmap(r.id.image_countdown, bitmap); try { appwidgetmanager.updateappwidget(appwidgetid, views); } catch (illegalargumentexception e){ e.printstacktrace(); } if(lastbitmap != null) { lastbitmap.recycle(); lastbitmap = null; } lastbitmap = bitmap; }
updatetime
called every second.
know that
the total bitmap memory used remoteviews object cannot exceed required fill screen 1.5 times, ie. (screen width x screen height x 4 x 1.5) bytes.
but can't find solution...
Comments
Post a Comment