开发者

android Alarmmanager doesn't repeat over long intervals

I'm sure I'm doing something wrong but I can't get the alarm manager to trigger more than once when I setup an alarm doing the following:

AlarmManager mgr = (AlarmManager) context.getSystemServi开发者_如何学运维ce(Context.ALARM_SERVICE);
Intent i = new Intent(context, ReminderAlarmReceiver.class);
i.setData(Uri.parse(REMINDER_ID + getReminderID() + getTriggerAtTime()));
i.putExtra(REMINDER_ID, reminderID);
i.putExtra(DiaryListItem.DIARY_ID, parentDiaryID);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
mgr.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtTime, AlarmManager.INTERVAL_DAY;, pi);

It seems to trigger the first day but doesn't trigger the next day. The same thing happens when I try to make a weekly or monthly alarm. Is there a better way of setting up long term alarms?


Did you mean to put that semicolon in your .setRepeating? I imagine your run would crash if it were actually still there:

mgr.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtTime, AlarmManager.INTERVAL_DAY;, pi);

should be

mgr.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtTime, AlarmManager.INTERVAL_DAY, pi);

If that was just a typo, does your logcat give any kind of error?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜