开发者

How do some app make their service running (relaunching it) even after killed ? Can android have any way to boot on power connect?

I have 2 questions:

  1. How do some android app make their service restart even if killed from task manager? A good example is Lookout security app. What I guess is that it has registered for all common events that are announced like app installed - unistalled, interenet available ,etc. Is this a way to keep your service running ? Another solution I found was to make 2 services monitoring each other, so if one gets killed restart another. Which one would be a proper approach ?

  2. Is there any way in android to start booting automatically(if device is switched off) once connected to power source ? I have never heard t开发者_JAVA百科his on mobile platform. This is possible for PC through bios feature. Can it be done on android ? Any ideas welcome.


1.) This is simple. All you have to do is return Service.START_STICKY from the services onStart() method. This tells the android OS to resume the service ANY TIME it is killed EXCEPT with a call to stopService()

2.) The only way this is possible is by modifying the firmware of the phone. When the phone is off, the android OS hasn't yet been started so there's no way to create an application that can run before the OS has been booted.


Answering this my own old question ..

  1. By registering for events as well as monitoring on apps may help but since 2.2 adds support for Service.START_STICKY this would rather be better option unless your app can't wait for O.S. to start. ( Like in case its antivirus which needs to be awake all time ).

  2. Not a solution yet. Support may come up if provided an option ( for e.g. like BIOS has this feature for PC ).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜