I am creating a AppWidget that consists of a ImageView that gets filled with a custom rendered bitmap. This widget is refreshed every minute (using the AlarmManager).
All the rendering and storage is done in the AppWidgetProvider.
Being a good citizen I wanted to minimize CPU usage etc, so I had my Paint objects and other pre-calculated values stored in static fields in the AppWidgetProvider.
However, it turns out that my AppWidget process is very eager to die on me when it’s hanging around with the cool kids doing nothing. I understand this is standard behaviour. However, with it’s tragic death, it also takes my precious statically stored objects with it into the grave, never to be seen again, which is a lot less convenient.
My mourning doesn’t solve anything, so I wonder: is there a way to deal with this? Or is there just no way to do that, and should I fall back to reinitializing everything on every redraw?
Not a real solution, but I solved it by not caching all the stuff.