I am developing an application that needs to constantly run a service unless the user consciously deactivates it. The problem is that there are taskkiller-apps with a "kill all applications"-button. These seem to become increasingly popular, and they are causing me a fuzz. When I kill my service with som task managers, onDestroy() is never run and all AlarmManagers are kille开发者_如何学JAVAd with the service. Is there any way to protect my service from these apps, or to restart my service immediately after it is killed?
Is there any way to protect my service from these apps, or to restart my service immediately after it is killed?
Not really, sorry.
Besides, if your service is well-behaved (i.e., not designed to run in memory all of the time), users will be less likely to kill it off using these tools. Services are not designed to run forever.
I ran into a similar problem, using "Advanced Task Manager" for Android. The app even has an "exlude list" where you can protect your apps from being killed by the Task Manager.
But still, my service would be killed, leaving it useless. I've been through loads of forums, trying to contact the author of ATM, but to no avail.
The solution (sounds like a bug in ATM): I had to exclude the service as well as the app that started the service in ATM to make it leave my app untouched (even though only the service was needed). Weird, but true.
精彩评论