I recently converted my long lived service(setForeground) app to one triggered by the AlarmManager. The nature of the work is I want to be woken up on intervals, but do not want to wake up the phone if it's not awake. And I don't want the duplicate alarms that you'd get with setRepeating. So according to the docs, the best way was to reschedule yourself each time with set. The call I'm making is this
PendingIntent pi=PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); mgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime()+msTillNext,pi); I'm using CANCEL_CURRENT because I am encoding setExtra data in the intent that is different for each call. Its waking an IntentService(specifically Mark's WakefulIntentService) This works, I see my app run over and over. I see my app being killed, and respawned via alarmReceiver. This all works great, but it randomly ceases. No exceptions in the log. I luckily have the log showing the last running of the service. The service runs, exits cleanly, and never runs again. I originally thought it could be that my msTillNext was negative, but the docs say that if the time is in the past, it will run immediately. It is a moto droid, running 2.1. Any suggestions? I'm about to write an alarm watchdog alarm to reschedule. or use setRepeating and store something in the DB to notice the dupes. 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

