I'd say trying STICKY and be careful to not swipe your app from the recents list (which kills the process... can be a support issue).
-- K 2014-02-01 dashman <[email protected]>: > yes this is on 4.4 > > i saw the startForeground API call - but my service really is a background > service... > > but i guess i'll have to use that now. > > > > > On Friday, January 31, 2014 3:34:41 PM UTC-5, Kostya Vasilyev wrote: > >> How many threads a service / process has "inside" does not have any >> effect on how likely it's to be killed. >> >> You should expect that your app's entire process, including any services >> (and threads, of course) can be killed by the system any time. >> >> Now since you mentioned swiping -- in case you're running 4.4, it appears >> to have a bug where swiping kills the process. >> >> In general, maintaining an ever-running service is not an easy task, >> unless you use the official "startForeground" API (which by design puts an >> icon into the status bar). >> >> Some (say, Mark Murphy who doesn't appear to be on this list anymore), >> would call it an "anti-pattern". I tend to agree. >> >> -- K >> >> >> >> 2014-02-01 dashman <[email protected]>: >> >>> I think your analysis is correct. >>> >>> I also think it happens because my service doesn't create a worker >>> thread. >>> >>> In the onStartCommand() method - it sets up some system listeners and >>> returns STICKY. >>> >>> So when the main app is being killed (when i remove it from the active >>> apps list) - i think the service >>> is being killed - but the onDestroy is not being called (as you >>> mentioned). >>> >>> I verified with the ps command - and it's gone. >>> >>> So should I create a worker thread or a handler - i will use it later on >>> for some work. >>> >>> >>> >>> >>> >>> On Friday, January 31, 2014 3:01:28 PM UTC-5, Kostya Vasilyev wrote: >>>> >>>> >>>> 2014-01-31 dashman <[email protected]>: >>>> >>>> >>>>> What's confusing is this. >>>>> >>>>> I've got the app and service running. >>>>> >>>>> Then using the active app-list option of the launcher, I remove the >>>>> app. >>>>> >>>>> >>>>> I would think this would kill the app - but not the service. >>>>> >>>>> Service.onDestroy() is not called. >>>>> >>>>> >>>>> But now if I restart the app - the Service.onCreate() is called >>>>> >>>>> >>>> Sounds like your app's process gets killed. When this happens, the >>>> service's onDestroy will not be called. >>>> >>>> Next when you start the app's UI (activity), the process is created >>>> again, and the service is too. >>>> >>>> You can watch this in the logcat, and for more details, use system >>>> settings -> apps -> running, or "adb shell ps", where "ps" is the standard >>>> Unix command that gives the list of running processes. >>>> >>>> -- K >>>> >>>> -- >>> 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 >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

