How can I repeat the alarm in android only on Mondays, Tuesdays and Fridays

How can I repeat the alarm on Android only on Monday, Tuesday and Friday.

Intent myIntent = new Intent(getApplicationContext(), x.class); PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); //Calendar calender = new GregorianCalendar(); Calendar calender = Calendar.getInstance(); calender.setTimeInMillis(System.currentTimeMillis()); calender.set(Calendar.HOUR_OF_DAY, hours); calender.set(Calendar.MINUTE, ireminder.getMin()); calender.set(Calendar.SECOND, 0); calender.set(Calendar.MILLISECOND, 0); calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,3); calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,2); calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,6); alarmManager.set(AlarmManager.RTC_WAKEUP, calender.getTimeInMillis(), pendingIntent); 

But it does not repeat for 3 and 6 days (Monday, Tuesday and Friday) Can you guys help?

+4
source share
1 answer

You need to set 3 separate alarms or make your alarm receiver smart enough to schedule the next alarm in previous fires. In your case above, it seems that only the value for "6" will be used, since it is the last set value.

0
source

Source: https://habr.com/ru/post/1346021/


All Articles