What is the correct way to ensure that a widget update service is restarted if it has been killed?
In my widget, I start the service in the onUpdate event, but if the widget and service are killed (by a task killer, for example), the widget restarts, but the service doesn't. On Aug 31, 6:01 pm, Kostya Vasilyev <kmans...@gmail.com> wrote: > A Service can still get killed together with its process if memory > gets low, so no guarantees. > > When there is a choice, the system is less likely to kill a service > that's either associated with a foreground activity, or a service that > explicitly marked itself as a foreground service (i.e. doing something > currently important for the user). > > Also, Services can be automatically restarted by Android at a later > point, while Activities are not (since Activities are driven by the user > doing something). > > http://developer.android.com/reference/android/app/Service.html#Proce... > > -- Kostya > > 31.08.2010 20:48, Agus пишет: > > > > > A thread hosted by the ApplicationContext will get killed by the > > System if necessary > > but not when hosted by a Service? > > > On Tue, Aug 31, 2010 at 9:22 AM, Kostya Vasilyev<kmans...@gmail.com> wrote: > >> The difference is that Activity lifecycle is managed by the user, and > >> Service lifecycle is managed by Android. > > >> The user can switch away from an Activity at any time, and, since Android > >> isn't aware that there is a worker thread, it can kill the process that > >> hosted the Activity (and the worker thread) pretty soon after that. > > >> A Service is a way to tell Android you're doing something important in the > >> background, and so the process has a higher chance to be kept alive (and > >> your worker thread working). > > >> -- Kostya > > >> 31.08.2010 20:05, cool.manish пишет: > >>> Service Component is used to do some task which can be done without > >>> user interaction. But for that we have to run a thread in subclass of > >>> the Service. > >>> I think we can create a thread in Activity class itself then what is > >>> the use of Service component? > >>> Why don't we create another thread and write the non interacting code > >>> in this thread. > > >> -- > >> Kostya Vasilyev -- WiFi Manager + pretty widget -- > >>http://kmansoft.wordpress.com > > >> -- > >> 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 > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com -- 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