tags:

views:

33

answers:

1

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 this on mobile platform. This is possible for PC through bios feature. Can it be done on android ? Any ideas welcome.

A: 

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.

Falmarri
Service.START_STICKY works only from API Level 5. I am trying for a solution for lower versions, at-least for API Level 4.
mob_king
Ah, didn't know it was >2.0. I'm not sure if there's a best way to do this on 1.5 and 1.6. Mutually monitoring services could be a solution. What is your service doing that you need it to stay alive?
Falmarri