我试图制作一个简单的作业提醒应用程序我使用此功能设置闹钟:
void setAlarm(int year, int month, int day, int hour, int minute, int second, String lesson, String description, int id)
{
Intent intent1 = new Intent(this, MyReceiver.class);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
intent1.putExtra("LESSON", lesson);
intent1.putExtra("DESC", description);
intent1.putExtra("ID", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) this.getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
人们说如果你想编辑你需要有完全相同的pendingIntent所以我做了但它似乎没有工作
当我设置闹钟并对其进行编辑而不关闭时,第一个闹钟似乎自动取消
我不知道我做错了什么
感谢您的帮助