[android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Mark Murphy
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(),

Re:: [android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Kostya Vasilyev
The data observer lifespan isn't tied to the receiver, it's a static. Also note that collection based widgets use other components, such as the remote views factory, and the service which acts as a factory for said factory (!). This service is implemented by the framework as sticky, what you

Re: : [android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Mark Murphy
On Thu, May 17, 2012 at 10:38 AM, Kostya Vasilyev kmans...@gmail.com wrote: The data observer lifespan isn't tied to the receiver, it's a static. It still goes away when the process does. Since it is only set up in onEnabled(), that means that once the process dies the first time, the observer

Re:: [android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Kostya Vasilyev
Besides, this observer monitors data published by a content provider that lives within the same process (if I'm understanding the structure correctly). So if there are changes, it means they were pushed by the content provider, which in turn means the process was alive. However, I believe it's

Re: : [android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Mark Murphy
On Thu, May 17, 2012 at 10:48 AM, Kostya Vasilyev kmans...@gmail.com wrote: However, I believe it's still wrong, as I see no reason for the widget provider's onEnabled to be called each time the process is recreated (such as by an alarm or the sticky remote views service). Unless, that is, I'm

Re: : [android-developers] Weather List Widget sample app: WTF?

2012-05-17 Thread Kostya Vasilyev
17.05.2012 18:55, Mark Murphy написал: I'd just push the app widget updates when updating the content provider and be done with the matter. I prefer using a worker thread wrapped in a service. The latter helps on devices with too little memory. All things said, a sample is just a sample.