I am developing one android application. I need to set a weekly alarm.
This is how I am setting weekly alarm:
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, WEEK_DAY_NUM);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, min);
calendar.set(Calendar.SECOND, sec);
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 24 * 7 * 60 * 60 * 1000, broadcast);
It is working as expected.
But I want to set alarms as below:
- A user can select the date, day and time
- If user Selected Date is Already Passed (i.e previous date compare to today's date)then I am setting alarm using today's date
- If user selected date is a future date consider this case: Today date is 21 Aug 2018 and user selected date is 23 Aug 2018 and user selected day is Friday and Time is 4 PM
How should I set alarm for this case? so it will start weekly repeating alarm every Friday at 4 PM after 21 Aug 2018.