On Dec 5, 7:56 am, Jon Colverson <[EMAIL PROTECTED]> wrote: > On Dec 5, 6:41 am, Jon Colverson <[EMAIL PROTECTED]> wrote: > > > I'd been having some weird issues with AlarmManager seemingly not > > firing my alarms when the device is asleep. I'm using the alarm to > > start a service and I was acquiring my wake lock in onStart(). I tried > > acquiring the lock in onCreate() instead, and that seems to have > > solved the problem. > > Oops. I spoke too soon. After some more testing that doesn't seem to > have helped.
I had another look at the AlarmManager documentation and I noticed that it only talks about using alarms to broadcast events, not start services. I changed things around to use a BroadcastReceiver instead that acquires the lock in its onReceive() and stored the lock reference as a static member of another class, following the example of the AlarmClock application: http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob_plain;f=src/com/android/alarmclock/AlarmAlertWakeLock.java;hb=HEAD That seems to have worked. I guess what was happening was that my service starting alarms were being fired, but the device was sometimes going back to sleep before I could acquire the wake lock. Apparently the only guarantee that is made when an alarm is received is that the onReceive will run to completion. I just thought I'd post this in case anyone is ever searching for the same problem. -- Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---