问题描述
我只想知道如何检测活动或服务已被高级任务杀手杀死?我期望调用onDestroy方法,但事实并非如此!
I just want to know how detect that the activity or service has been killed by the advanced task killer? I was expecting the onDestroy method to be called, but it doesnt!
我的应用程序在启动时启动后台服务.除菜单外,该活动未开始.但是它的名称出现在高级任务杀手列表中.当我尝试杀死它时,它既不调用服务也不调用onDestroy方法.
My app starts the background service on boot. The activity is not started except from menu. But its name appears in the advanced task killer list. When I try to kill it, it doesnt call the onDestroy method neither the service's.
有什么想法吗?
谢谢.
推荐答案
以这种方式终止任务时,您不会收到任何通知.
You do not receive any notification when your task is killed in this fashion.
在许多情况下,将不会调用活动或服务的onDestroy()
.这就是其中之一.
There are various scenarios in which onDestroy()
of an activity or service will not be called. This is one of them.
我衷心希望服务能在几秒钟后关闭.否则,请考虑是否您在做什么是正确的东西.
I sincerely hope that service shuts down in a few seconds. Otherwise, please consider whether what you are doing is the right thing.
这篇关于Android:如何知道被高级任务杀手杀死的活动/服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!