重新创建 PendingIntent,并使用 PendingIntent.FLAG_ONE_SHOT 替换 PendingIntent.FLAG_UPDATE_CURRENT。
代码示例:
// 创建 PendingIntent PendingIntent pendingIntent = PendingIntent.getService(context, requestCode, new Intent(context, MyService.class), PendingIntent.FLAG_ONE_SHOT);
// 使用 PendingIntent AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);