I have an appwidget that uses a service for much of its work. The appwidget calls Context.startService() to initially start the service and then calls it again whenever it has work for it to do.
In the service's onCreate() method I initialize a number of booleans that are used to remember state. These variables are also initialized when they are declared. In the service's onStart() method I check and update the booleans as needed. Depending on the value of these booleans the service will send one of two notification messages are none at all. For the most part, things work fine. However, at random times I receive a notification even though I know that the booleans should not have been set that way. Is it possible that I have misunderstood the service lifecyle and/or how it keeps state? Is it possible for a service's onCreate() method to be called after it was already created (which would screw up my booleans) even though the service is already running? Actually, maybe a better question is whether Android might be calling onDestroy() even though I haven't asked it to! If that is the case, what would cause that to happen given that my appwidget is regularly using the service? And if this is something I have to deal with, how do I preserve state across this situation? And how do I distinguish between the service being destroyed because Android chose to do it (in which case I need to preserve my state) and it being destroyed because the widget was deleted from the homescreen (in which case I do not need to preserve my state)? Thanks. -- Jake Colman -- Android Tinkerer -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

