Closed justdave closed 10 years ago
This is what I get for following someone's bad sample code :-) What I did was try to set up a service that handled the widgets and that service in turn registered with the background service as a listener to get notified when there was new data. The problem is the widget service itself ends up getting killed off periodically, too, and it's not registered as a system service, so it doesn't get restarted again until something requests it (like the home screen getting killed and having to rebuild the widget). It looks like the correct way to do this is to have the real background service send an Intent to the widget provider to tell it that there is new data (instead of just an IPC notification like it's doing currently), which would then relaunch the widget provider if it wasn't running anymore so it could do the update.
Er, I think I broke it. Now, after a while, it blanks out instead of failing to update. You can successfully restart it by going into the config and switching to a different county though.
If the background service gets killed (common occurrence, Android does it all the time for memory management), the OS will restart it again as soon as there's free resources for it again. This is fine. The problem is that the widget is failing to resubscribe to it when it comes back, so once the background service gets killed once, the widget never updates again.