Can I detect when my service is killed by “Advanced Task Killer”

核能气质少年 提交于 2019-12-03 13:56:05

When a process is killed (using ATK or android's own force stop button, or the function here), it is immediately purged from memory (if the kernel allows it). This means there's no chance for any additional code to run, meaning there is no way to really deal with a "force kill" sent to your application.

If you want to handle this, you have 2 options (that I can think of):

  1. Publish a disclaimer telling users to add your app to the "ignore" list of ATK.
  2. Find some way to maintain functionality without relying on the onDestroy() method.

EDIT:

If you want to check for your process from a list of currently-running processes, look into getRunningAppProcesses().

Mikonos

onDestroy()

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!