是否可以在每次触发时更改 AlarmManager Intent?

Is it possible to change AlarmManager's Intent every time it fires?

是否可以更改 Intent 以及每次触发 AlarmManager 时的额外内容?

AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, Alarm.class);
// Extras aren't used to find the PendingIntent
PendingIntent pi = PendingIntent.getBroadcast(context, tag, i,
        PendingIntent.FLAG_NO_CREATE); // find the old PendingIntent
if (pi != null) {
    // Now cancel the alarm that matches the old PendingIntent
    am.cancel(pi);
}
// Now create and schedule a new Alarm
i = new Intent(context, NewAlarm.class); // New component for alarm
i.putExtra("position", tag); // Whatever new extras
pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT);
// Reschedule the alarm
am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute

是的,每次你需要取消当前的并启动新的,如果你想在 Intent 中进行任何更改,如数据附加、操作、组件等。