0
我设置了一个AlarmManager,它会在一段时间后重复发出警报。我为此使用了以下代码。Android AlarmManager执行时间问题
Intent intent = new Intent(ViewDoughnut.this, NotificationMessage.class);
PendingIntent sender = PendingIntent.getBroadcast(ViewDoughnut.this, 0, intent,PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP,nextAlarmTime, alarmInterval, sender);
现在要在闹钟的时候执行正确的工作,我已经创建了以下扩展BroadcastReceiver的类。现在我需要以毫秒为单位的时间,当警报工作应该在该类中执行时。如何得到它?
public class NotificationMessage extends BroadcastReceiver {
// Display an alert that we've received a message.
// @Override
public void onReceive(Context context, Intent intent) {
// here I need the time when the alarm should execute.
}
}
在这里我想补充,系统时间是不是为我工作,因为如果该设备是在警告时关掉,它执行的是当设备在此时间之后开启。但我需要时间来执行它。
这对我的情况不会有效,因为它是一个重复闹钟,并且多个闹钟对于不同事件同时有效。 – 2011-04-26 13:36:33