Skip to content

Instantly share code, notes, and snippets.

@leviyehonatan
Created May 23, 2016 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leviyehonatan/167db319efd56bb65b2c02c95d0d45cf to your computer and use it in GitHub Desktop.
Save leviyehonatan/167db319efd56bb65b2c02c95d0d45cf to your computer and use it in GitHub Desktop.
fun setExactAlarm(type: Int, triggerAtMillis: Long, operation: PendingIntent ) {
if (Build.VERSION.SDK_INT >= 23)
alarmManager.setExactAndAllowWhileIdle(type, triggerAtMillis, operation)
else if (Build.VERSION.SDK_INT >= 19)
alarmManager.setExact(type, triggerAtMillis, operation)
else
alarmManager.set(type, triggerAtMillis, operation)
}
setExactAlarm(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + (1000 * notification.active_after),
PendingIntent.getBroadcast(context, 0, notificationMessageIntent, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment