try using setExactAndAllowWhileIdle at Android 6+ for scheduling notifications
This commit is contained in:
parent
96ce109aa6
commit
89615acf89
1 changed files with 4 additions and 4 deletions
|
@ -96,10 +96,10 @@ fun Context.scheduleEventIn(notifTS: Long, event: Event) {
|
|||
val pendingIntent = getNotificationIntent(applicationContext, event)
|
||||
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
|
||||
if (isKitkatPlus()) {
|
||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||
} else {
|
||||
alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||
when {
|
||||
isMarshmallowPlus() -> alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||
isKitkatPlus() -> alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||
else -> alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue