我对 Android 中的警报管理器有疑问。我有以下代码片段来设置每周(一次)应该触发的警报。
// Add the time and set when the notification will be triggered
Calendar setCalendar = item.getDate();
calendar.set(Calendar.MINUTE,setCalendar.get(Calendar.MINUTE)+10080);
//Create a new alarm intent
Intent alarmIntent = new Intent(ApplicationUtils.getApplicationContext(), AlarmReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(ApplicationUtils.getApplicationContext(), requestCode, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the AlarmManager service
AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.ELAPSED_REALTIME, sender);
我必须关注问题。当一周改变时,通知就会出现并且它们永远不会停止。有人知道如何设置日历以便每周触发一次警报吗?
谢谢,阿克德