0
我有保存在TimeInterval對象中的每週時間表,它們工作正常。我構建了一個循環,因此我可以爲每個人設置一個鬧鐘。我的代碼不起作用,我錯過了什麼?Android警報管理器循環中的多個待定目標
此外,我如何從另一個線程的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++;
}