From 34f83f74bfa9f0cc432884137bc0b412b85ef561 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 14 May 2017 22:12:30 +0200 Subject: [PATCH] use a helper function for checking KITKAT --- .../com/simplemobiletools/calendar/extensions/Context.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index 557ce800b..bd220b9fa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -19,6 +19,7 @@ import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.calendar.receivers.NotificationReceiver import com.simplemobiletools.commons.extensions.getContrastColor +import com.simplemobiletools.commons.extensions.isKitkatPlus import com.simplemobiletools.commons.extensions.isLollipopPlus import org.joda.time.DateTime import org.joda.time.DateTimeZone @@ -121,7 +122,8 @@ fun Context.scheduleEventIn(notifTS: Int, event: Event) { val notifInMs = SystemClock.elapsedRealtime() + delayFromNow val pendingIntent = getNotificationIntent(this, event.id) val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) + + if (isKitkatPlus()) alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent) else alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent)