Showing posts with label RTFM. Show all posts
Showing posts with label RTFM. Show all posts

Monday, October 11, 2010

Appwidget lifetimes and persistance of data

So tonight's aggravation was caused by the letter null. Basically I couldn't figure out when I was trying to get my Speed Widget to work, why I could create a locationManager and initialize it, but subsequent calls would throw a NullPointerException.

The solution (as with most things), was to RTFM. If you look at the documentation for BroadcastReceiver (Which AppWidgetProvider is extended from), you would see:
A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent).
So that pretty much solved why my local variables were disappearing each time. I figured that appwidgets had funky lifetimes, I just didn't know where to look.