Repeat Alarm once in a week in android

前端 未结 2 1366
星月不相逢
星月不相逢 2020-12-18 06:42

I am trying to develop alarm functionality in a my app which runs on a week days specified by user on fixed time. Problem here is that my scheduler running for all days inst

2条回答
  •  Happy的楠姐
    2020-12-18 07:35

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, Seconds, AlarmManager.INTERVAL_DAY, pendingIntent);
    

    In this line you set the start time to the user selected day, but then set the interval to INTERVAL_DAY.

    You should use INTERVAL_DAY * 7 to make sure it repeats on a weekly basis instead:

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, Seconds, AlarmManager.INTERVAL_DAY * 7, pendingIntent);
    

提交回复
热议问题