The Android Developers site has a Weather List Widget sample app:

http://developer.android.com/resources/samples/WeatherListWidget/index.html

One of the classes in it is WeatherWidgetProvider, which is an
AppWidgetProvider. This AppWidgetProvider is registering a
ContentObserver in onEnabled(), by means of a HandlerThread.

Am I missing something, or is this very broken?

AppWidgetProvider is a BroadcastReceiver. Our process may be
terminated milliseconds after any of the AppWidgetProvider lifecycle
methods (e.g., onEnabled()) returns, if there are no other components
running.

So, the way I see it:

-- this code is leaking a thread, as the HandlerThread is not being
managed by any component

-- this code is unreliable, as once the process is terminated, the
ContentObserver is gone

Has anyone seen this pattern used in production code?

Thanks!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

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

Reply via email to