Sahil Mahajan Mj
Sahil Mahajan Mj

Reputation: 11141

Invoke a Service even when the Device is Switched Off

I am working on a Security application, where i need to play siren music on receiving certain text(say "siren").

So far, I've been able to receive the SMS intent and play the .mp3 siren music. But the problem encounters when the device is switched off.

Its been to my knowledge that there are some Intents(dont know what exactly to call them), those intents are fired even when the Device is switched off, just like the Scheduled Alarms (which executes even when the phone is switched off)

If anyone knows about those services or whatever they are, it would be helpfull if you share those ideas.

Upvotes: 1

Views: 692

Answers (2)

Charlie
Charlie

Reputation: 53

Maybe this might help.. Shouldn't be that hard to do but how can you get a text message if the phone is turned off?!

http://developer.android.com/reference/android/app/AlarmManager.html

Upvotes: 0

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

If you need device to be awaken when you do your tasks, then simply wake it up using PowerManager. Please note that once your onReceive() is completed device may fall back to sleep, so if you spawn some other processed in your BroadcastReceiver, you need to hold WakeLock.

You may take a look at this as well: https://github.com/commonsguy/cwac-wakeful

Upvotes: 2

Related Questions