Experts: Any experts on AlarmManager out there? I've got something weird going on.
The basic code to set my repeating alarm works fine. I can close my app and the alarm will continue to run like clockwork every five minutes. It works fine only if I set it in the app and then close the app. The code is below: -------------------------------------------------------------------------- Intent intent = new Intent(this, AlarmReceiver.class); Bundle b = new Bundle(); b.putLong("res_id", res_id); intent.putExtras(b); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, (System.currentTimeMillis() + (5 * 1000)), (5 * 60000), pendingIntent); -------------------------------------------------------------------------- I've got a registered BootReceiver for re-registering the repeating alarm. I know it fires on boot b/c the log message clearly shows it is firing and re-setting the repeating alarm in question for the same frequency. But the AlarmManager is not firing. Basically, the nearly identical code for setRepeating() fires when set from the app and continues to run when the app is closed, so I know my AlarmReceiver is functioning, but the AlarmManager is either not broadcasting this alarm or my receiver doesn't work from an alarm set in the boot receiver. Below is the code for setting the alarm from the BootReciver: -------------------------------------------------------------------------- Intent i = new Intent(context, AlarmReceiver.class); Bundle b = new Bundle(); b.putLong("res_id", res_id); i.putExtras(b); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, (int)res_id, i, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, (System.currentTimeMillis() + (5 * 1000)), (5 * 60000), pendingIntent); -------------------------------------------------------------------------- I read somewhere that the AlarmReceiver definition in the manifest needs an intent-filter or 2 specified. I don't have any intent-filters, nor would I know what to put in there. Is that perhaps why? I mean it could make sense b/c the call to setRepeating from the activity w/in my app would still work b/c the broadcast has more information about what receiver needs the alarm, whereas when it's being set from the bootreceiver, the receiver in my manifest isn't defined well enough to get the broadcast? Here's my manifest definition for the receiver: <receiver android:name=".AlarmReceiver" android:process=":remote" /> At the following PDF (Page 25), it suggests a fully-qualified app name intent-filter: http://docs.huihoo.com/google/io/2009/W_0300_CodingforLife-BatteryLifeThatIs .pdf Thanks, Nick Owens VP, ThreeClix Office: (904) 429-7039 Mobile: (847) 565-9392 After Hours: (904) 540-5830 -- 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 android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en