Nothing is guaranteed in that case, unfortunately. That's why I wrote WakefulIntentService, to try to help package up the pattern for dealing with this circumstance:
https://github.com/commonsguy/cwac-wakeful On Mon, Nov 29, 2010 at 9:10 PM, Robin <[email protected]> wrote: > Hi all, > I am using AlarmManager to schedule a repeated action which starts a > service: > > PendingIntent mAlarmSender = PendingIntent.getService(context, 0, new > Intent(context, MyAndroidService.class), 0); > alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, > firstRunMills, interval, mAlarmSender); > > I saw the following paragraph in AlarmManager's document: > The Alarm Manager holds a CPU wake lock as long as the alarm > receiver's onReceive() method is executing. This guarantees that the > phone will not sleep until you have finished handling the broadcast. > Once onReceive() returns, the Alarm Manager releases this wake lock. > 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. > > But it looks that the CPU wake lock can only be applied to pending > intents created by PendingIntent.getBroadcast. I am wondering when the > wake up lock is be released if the PendingIntent is an service. Does > anyone has insight into this? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

