Thanks Jon. It works very well for me. You saved me a day. Thank you.
Hai On Sunday, December 7, 2008 2:56:10 PM UTC+7, Jon Colverson wrote: > > 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 [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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

