0

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:

  1. A user can select the date, day and time
  2. 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
  3. 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.

Harsh Shah
  • 2,162
  • 2
  • 19
  • 39
  • refer this https://stackoverflow.com/questions/4700285/android-how-to-set-an-alarm-to-a-specific-date –  Aug 21 '18 at 07:22
  • @AndroidTeam thank you for your reply but I have one doubt: If I set a date(23 Aug 2018) and day (Fri) and in the calendar and set interval of 7 days then it will repeat after 7 days (30 Aug) or it will repeat every Friday (starting from 24 Aug 2018). – Harsh Shah Aug 21 '18 at 07:30

0 Answers0