I am new to android and have problems with setting a repeating alarm. The app is like this: user selects time using a timepicker, and selects several days to set the alarm. I use this code to implement this task:
for(int i=0; i < alarm.getDaysOfTheWeek().size(); i++){
// here is a switch block to assign daysUntilAlarm1
//to a particular day from the list of selected days, like
//daysUntilAlarm1 = Calendar.SUNDAY;
calendar.set(Calendar.DAY_OF_WEEK, daysUntilAlarm1);
calendar.set(Calendar.HOUR_OF_DAY, alarm.getHour()); // hour picked by user
calendar.set(Calendar.MINUTE, alarm.getMinute());
pendingIntent = PendingIntent.getBroadcast(AlarmManagerActivity.this, i, intentToAlarmReceiver, 0);
pendingIntents.add(pendingIntent);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 7 * 24 * 60 * 60 * 1000, pendingIntent);
The problem is when I test alarms, I change the system time to the next alarm day. Everything works fine. But when I change the system time to the past, like last week, the alarm doesn't work. So if user will have to change the time of the device to past, the app will not work. Can anyone help me, please?