mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
try using setExactAndAllowWhileIdle at Android 6+ for scheduling notifications
This commit is contained in:
@@ -96,10 +96,10 @@ fun Context.scheduleEventIn(notifTS: Long, event: Event) {
|
|||||||
val pendingIntent = getNotificationIntent(applicationContext, event)
|
val pendingIntent = getNotificationIntent(applicationContext, event)
|
||||||
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
|
|
||||||
if (isKitkatPlus()) {
|
when {
|
||||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
isMarshmallowPlus() -> alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||||
} else {
|
isKitkatPlus() -> alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||||
alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
else -> alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user