Friday, September 24, 2010

[android-developers] Null pointer in AppWidgetManager.getInstance()

I'm getting a null pointer in app widget manager. I believe it is when
the user is upgrading the app while a background intent service is
running, possibly right before the widget is updated. The background
service updates a database and the appWidgets right before it
terminates.

This is from 2.2
java.lang.NullPointerException
at android.appwidget.AppWidgetManager.<init>(AppWidgetManager.java:230)
at android.appwidget.AppWidgetManager.getInstance(AppWidgetManager.java:221)

I've looked at the code above, and it seems to be
context.getResources.getSomething where it Null pointering. The
context is non-null, since the getInstance was called with "this". So
its probably the resources being null at that point

Is there a broadcast intent that I could catch to tell my intent
service to shut down? The docs are a bit confusing in the
PACKAGE_RESTART, PACKAGE_REMOVED, and PACKAGE_REPLACED usage. REPLACED
seems to be sent to the new instance of the app only. Are any of these
sent to the old version of the app prior to it being upgraded? Is
Application.onDestroyed() guaranteed to be called on clean shutdown
due to upgrade?

I also get occasional database locked, also right around the time I
release the update. Its probably caused by the same thing(old version
running concurrently).

Thanks!

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment