How to stop Android service ONLY when there are no other actions in my application?

Is there any way to check if there are any other actions in my application still alive? I want to stop the service in the onDestroy method, but I want to do this only if there are no other actions from my application still live on the stack.

I have a call to stop the service in the main onDestroy () method. This works great if the user launches my application and then launches several actions in my application, and then gets to the main screen and relaxes my application, they destroy my order and the main action will now be higher than other actions of my application. From this state, if they press the back button and return on my home screen, they will call the onDestroy () method and kill the service, even if other actions are open on the stack. I want to avoid this by stopping the service ONLY if I'm sure there are no other actions in my stack. Is it possible?

+3
source share
1 answer

, , , , ?

startService() stopService(). bindService() unbindService(), . / . bindService() BIND_AUTO_CREATE, bindService() . , bindService() unbindService(), Android .

+16

All Articles