2
votes

As stated by the AlarmManager docs:

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

This means that the phone will in some cases sleep as soon as your onReceive() method completes. If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available.

From what I've seen and read here: http://www.androidguys.com/2009/04/02/wake-up-with-the-alarm/ https://github.com/commonsguy/cw-advandroid/blob/master/SystemServices/Alarm/src/com/commonsware/android/syssvc/alarm/WakefulIntentService.java

That guys holds onto the wake lock through the service not just until it becomes available. So my question is, will a service allow the CPU to sleep if it does not have a wake policy running through the service?

1

1 Answers

0
votes

So my question is, will a service allow the CPU to sleep if it does not have a wake policy running through the service?

Of course. Think of a laptop that sleeps when one closes its lid (the silly default). Some method somewhere will be interrupted - be it the main() method of the currently running application