更新时间:2023-11-19 11:12:01
如果日历 calendar.before(Calendar.getInstance())==真
(这意味着你是设置报警,在过去的开始,它会立即触发。
If calendar calendar.before(Calendar.getInstance()) == true
(it means your are setting alarm to start in the past, it will fire immediately.
在这种情况下,你可以做如下:
In such situation you can do following:
long start = calendar.getTimeMillis();
if (calendar.before(Calender.getInstance()) {
start += AlarmManager.INTERVAL_DAY * 7;
}
// set alarm with start time
从文档:
如果在过去发生的时间,该报警器将被立即根据触发时间如何在过去远是相对于重复间隔触发,与报警计数。
If the time occurs in the past, the alarm will be triggered immediately, with an alarm count depending on how far in the past the trigger time is relative to the repeat interval.