by the way, is there any way to know when Android is about to "force- close" your process / service?
On Sep 10, 4:24 am, sdphil <[email protected]> wrote: > based on some other posts I have seen, I created a static variable > inside my service class and I initialize it to false. when the > service is created, I set it to true. > > public class MyService extends Service { > private static boolean running = false; > ... > ... > @Override > public void onCreate() { > super.onCreate(); > > running = true; > ... > ... > > then when I come back up, I can just check if Service.running is true > - if it is, then my service object is still alive. > > to answer your question more specifically - I do have a background > thread, but the whole point was that I wanted this service to run even > though the app was closed (i.e. no activities) (isn't that the point > of a service) ? > > "Otherwise, the service object, while detached from Android, will live > until the thread terminates, or until Android force-closes your > process due to lack of memory." > > which is exactly what I want... > > tia. > > On Sep 10, 4:05 am, Mark Murphy <[email protected]> wrote: > > > sdphil wrote: > > > i have a local service (based on LocalService). > > > > when I start my app, the service gets created. > > > > when I back out of my app (continuing to hit "back" until I get to the > > > desktop), my service's onDestroy() gets called, but the service is > > > still alive (presumably until android decides it's low on system > > > resources and kills it). > > > How do you know that "the service is still alive"? > > > If it is because you have a background thread, you need to stop that > > background thread in onDestroy(). Otherwise, the service object, while > > detached from Android, will live until the thread terminates, or until > > Android force-closes your process due to lack of memory. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://twitter.com/commonsguy > > > Need Android talent? Ask on HADO!http://wiki.andmob.org/hado --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

