Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
The problem with bind/unbind - is that when the activity finishes the service gets stopped. I want the service to be around - even if the mainactivity is killed. in the Activity.onCreate() i do Intent requestIntent = new Intent(this, MainService.class);

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
The problem with bind/unbind - is that when the activity finishes the service gets stopped. I want the service to be around - even if the mainactivity is killed. I kill the mainactivity by going to the active app list and removing it. Then when I go to the phone SettingsApps and look at the

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread TreKing
On Fri, Jan 31, 2014 at 8:19 AM, dashman erjdri...@gmail.com wrote: The problem with bind/unbind - is that when the activity finishes the service gets stopped. I want the service to be around - even if the mainactivity is killed. Ah. Well, a little hacky, but you could save a boolean

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
Absolutely - happy to explain. My service can be started at phone bootup - works wonderfully. Now when the user starts my app (Activity) - in the onCreate method i want to see if the service is running - if not running - i want to run it. I've taken your advice and in the

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread TreKing
I was asking more along the lines of what is your service actually doing. What is its purpose that requires this limitation? Is it a long-running task it's executing or something quick? In any case, on further thought: Service.onCreate() should only be called if the service is not already

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
The service doesn't do much right now - in fact I'm not creating a worker thread in onStartCommand() But it is a listener for some system callbacks - but later I might add a worker thread - will always be running. Basically I want a single instance of the service running all the time. I read

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
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

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread Kostya Vasilyev
2014-01-31 dashman erjdri...@gmail.com: 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

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
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

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread Steve Gabrilowitz
Short answer to the subject line: private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(this.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread Kostya Vasilyev
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

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
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

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread dashman
calling startForeground() seems to have done the trick. Not entirely comfortable because it's not a foreground service - but it does need to be there on at least until the user tells it to stop - I hope it's not eating up too much resources. Thanks everyone. -- You received this

Re: [android-developers] Checking to see whether my service is running/active

2014-01-31 Thread Kostya Vasilyev
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 erjdri...@gmail.com: yes this is on 4.4 i saw the startForeground API call - but my service really is a background service... but

[android-developers] Checking to see whether my service is running/active

2014-01-30 Thread dashman
I've got a service class that runs in the background. I'd like to make calls from my main activity to the service object. In the Activity.onCreate() method - if the service is not running - i'd like to start it. The way i did it - was in the Service.onCreate() method - i set a static variable

Re: [android-developers] Checking to see whether my service is running/active

2014-01-30 Thread TreKing
On Thu, Jan 30, 2014 at 5:14 PM, dashman erjdri...@gmail.com wrote: I've got a service class that runs in the background. I'd like to make calls from my main activity to the service object. In the Activity.onCreate() method - if the service is not running - i'd like to start it. I think