On Fri, Jun 18, 2010 at 1:57 PM, Mark Murphy <[email protected]>wrote:
> On Fri, Jun 18, 2010 at 2:54 PM, Robert Macaulay > <[email protected]> wrote: > > Well, the < 10 ms check didn't help. dumpsys alarm just shows that it > used > > to run, but nothing currently scheduled. > > I have no exceptions logged, and the reschedule is in a finally block. > > What is the approximate duration between your alarms (the ones you > have been doing with set())? I'd like to take a shot at trying to > reproduce your problem. > > Also, what device(s) are you testing this on? The device is a Moto Droid The current set logic is like this: X = uptimeMillis() The current interval is 2 minutes, ELAPSED, no wakeup. on the alarm intent, I attach 120000(2 minutes), and X, set with FLAG_CANCEL_CURRENT to get the new extras pushed in. In non sleep case, I wake up, do a uptimeMillis(), assert it's been 95% of the desired poll time(120000*.95 + X) and continue. At the end, it reschedules based on same logic The trick happens when the device is sleeping. If the CPU is off, the uptimeMillis() does not advance, I didn't want to wakeup. So when the alarm fires early(in awake time), I check the uptimeMillis() and see its been no where near the desired 2 minute sleep, and reset the alarm to the missing delta time - I added a ms = ms < 10 ? 10 : ms; to ensure non-negative. For example X=0 uptimeMillis(); poll=120000 schedule alarm wakeup(its been 2 minutes wall clock, the phone has been sleeping) Y = 10000 uptimeMillis() This is 110000 uptimeMillis early, so go back to sleep for 110000ms I'm going to attach a file debug print to my scheduling operations and service operation cycle and see if I can get a log of the problem. Can I use setRepeating for the same logic? I see that it will deliver the same way as the set will, the thing that is not clear is when it will deliver the repeat. For example, if I schedule an alarm for now+120,000 with a 10,000 delay and the phone sleeps for 149,000 and wakes up, what will happen? Will the repeat happen in 10,000 ms from the delivery of the late alarm, or will it deliver it immediately after the late alarm is serviced? The docs seem to indicate it will hit the next interval. So if the late alarm is delivered seconds before the interval, you'd get 2 intents delivered back to back. Thanks -- 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

