In my particular situation, I was using onCreate() to initialize state variables to their initial values. My expectation was that onCreate() is called just once for the lifetime of my app. Now that I know that Android can destroy my service if needed and cause it to be recreated, that form of initialization won't work for me. That being the case, I moved that logic to onHandleIntent() where it initializes the state variables from persisted storage.
Incidentally, onStart() is deprecated and onStartCommand() is not recommended for override according to the docs; it specifically states that you should override onHandleIntent() instead. >>>>> "IV" == Indicator Veritatis <[email protected]> writes: IV> Well, I hope this doesn't turn out to be an irrelevant IV> distraction, but did you really have to move the code from IV> onCreate and onStart? Not every IntentService can implement only IV> onHandleIntent the way Google's sample does in IV> http://developer.android.com/guide/topics/fundamentals/services.html#ExtendingIntentService IV> The same doc does, after all, specifically address this need in IV> "If you decide to also override other callback methods, such as IV> onCreate(), onStartCommand(), or onDestroy(), be sure to call the IV> super implementation, so that the IntentService can properly IV> handle the life of the worker thread." IV> But in what you described, what was happening only when the IV> Service was created is now happening every time you get an IV> Intent. Maybe for your Service it makes no difference, but in IV> general, that is quite a change. IV> On Feb 23, 2:54 pm, Jake Colman <[email protected]> wrote: >> >>>>> "KV" == Kostya Vasilyev <[email protected]> writes: >> >> KV> Based on your code - is your service class in a different package >> from the >> KV> widget class? >> >> No. Everything is in the same package. Everything about this >> package was working and I was able to update the widget. The only >> change I made was recode ZMUpdateService to extend IntentService >> instead of Service and to move code from the onCreate and onStart >> methods to the onHandleIntent method. That's why am I asking all >> these questions about differences between using a Service and an >> IntentService - although based on all the answers there isn't any! >> >> -- >> Jake Colman -- Android Tinkerer IV> -- IV> You received this message because you are subscribed to the Google IV> Groups "Android Developers" group. IV> To post to this group, send email to [email protected] IV> To unsubscribe from this group, send email to IV> [email protected] IV> For more options, visit this group at IV> http://groups.google.com/group/android-developers?hl=en -- 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

