0
這項工作?重複報警通知(Android)
public void setRepeatingAlarm() {
ArrayList<Integer> AlarmDays = datasource.getDays();
final int _id = (int) System.currentTimeMillis();
Log.d("AlarmManageDebt", String.valueOf(AlarmDays));
for (int i : AlarmDays) {
Calendar cal = Calendar.getInstance();
if (cal.get(Calendar.SECOND) >= 30)
cal.add(Calendar.MINUTE, 1);
cal.set(Calendar.SECOND, Integer.valueOf(i));
Intent intent = new Intent(this, TimeAlarm.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, _id,
intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
60 * 1000, pendingIntent);
}
}
我對的PendingIntent一個唯一的ID,並在報警唯一不同的是「我」的變量,賦予其新的秒,這取決於數據庫行(最終,這將是一個日用品的通知和「i」代表一天,而不是第二次,但是這是爲了測試的目的,我已經確認正確的數據正在通過「我」,我只是不確定這是否會產生三種不同的警報?所以我在這裏創建多個鬧鐘?或者是每個循環有效地取代剛創建的鬧鐘?