Is there an accurate repeating-alarm system for Android?

有些话、适合烂在心里 提交于 2019-12-04 16:58:13

You can separate before API 19 and after API 19. While setting alarm for the first time:

            if (Build.VERSION.SDK_INT >= 19) {
                alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), mondayIntent);
            } else {
                alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                        AlarmManager.INTERVAL_DAY * 7, mondayIntent);
            }

When you catch the alarm:

    if (Build.VERSION.SDK_INT >= 19) {
        rescheduleAlarm();
    }

You must set the alarm with

setexact

again in rescheduleAlarm.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!