开发者

How to relaunch a application immediately in android after being killed?

开发者 https://www.devze.com 2023-04-02 18:41 出处:网络
Hi i make an antivirus and anti theft application on android. I want to relaunc开发者_Python百科h my application immediately after being killed by a task killer. For now, i only use START_STICKY metho

Hi i make an antivirus and anti theft application on android. I want to relaunc开发者_Python百科h my application immediately after being killed by a task killer. For now, i only use START_STICKY method from service, but it takes a few time to restart my application and service after being killed. My antivirus and anti theft application should be launch immediately because if the owner's mobile phone was lost, an owner still can monitoring where the last location of their mobile phone. Has anyone know how to restart an application on android immediately which is better than START_STICKY method? like a Lookout mobile security?


The best thing you could do is use a service activity, this cannot be killed by task killers if I remember this right :)!

A service is made by making a simple extension like this:

public class MyService extends Service {

And you can start this with this:

startService(new Intent(this, MyService.class));

And stop this with

stopService(new Intent(this, MyService.class));
0

精彩评论

暂无评论...
验证码 换一张
取 消