Can I detect when my service is killed using Advanced Task Killer

My application starts the geolocation service, which the user can activate or deactivate using toggleButton. To check the status of a service, I write a boolean in the general settings. I listen to the beginning of the service and its end thanks to the onDestroy () service.

My problem is that: when a user kills a service using the "extended task killer", I cannot know that the service is killed, onDestroy is not called!

How can I handle this?

Thank you for your help.

Florent

+7
source share
2 answers

When a process is killed (using the ATK or Android stop button, or the function here ), it is immediately cleared from memory (if the kernel allows it). This means that there is no chance to run any additional code, that is, there is no way to really deal with the β€œforce kill” sent to your application.

If you want to deal with this, you have 2 options (what I can think of):

  • Post your opt-out statement so that users add your application to the ATK ignore list.
  • Find a way to maintain functionality without relying on the onDestroy () method.

EDIT:

If you want to check your process from the list of current processes, check out getRunningAppProcesses () .

+2
source

onDestroy()

If you want to restart the service, you can restart it in onDestroy() .

-one
source

All Articles