我有一个保存在 TimeInterval 对象中的每周计划,它们工作正常。我构建了一个循环,这样我就可以为每个人设置一个警报。我的代码不起作用,我错过了什么?
此外,如何从另一个线程的 BroadcastReceiver 取消这些警报?
for(ArrayList<TimeInterval> day : days){
for(TimeInterval ti : day){
numberofintents++;
Intent i = new Intent(getApplicationContext(),ChangeMode.class);
i.putExtra("ringermode", ti.getRingerMode());
PendingIntent pending = PendingIntent.getService(getApplicationContext(), id, i,PendingIntent.FLAG_CANCEL_CURRENT);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MINUTE,ti.getMinute()%60);
cal.set(Calendar.HOUR_OF_DAY,ti.getMinute()/60);
cal.set(Calendar.DAY_OF_WEEK,dayofweek);
Log.d(TAG, cal.get(Calendar.HOUR_OF_DAY)+":"+cal.get(Calendar.MINUTE));
service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 1000*60*60*24*7, pending);
id++;
}
dayofweek++;
}