This commit is contained in:
vfsfitvnm
2022-07-22 21:28:59 +02:00
parent 6474b52490
commit 6a8fdb7c11
4 changed files with 15 additions and 6 deletions

View File

@@ -21,9 +21,10 @@ inline fun <reified T: BroadcastReceiver> Context.broadCastPendingIntent(
inline fun <reified T: Activity> Context.activityPendingIntent(
requestCode: Int = 0,
flags: Int = if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0,
flags: Int = 0,
block: Intent.() -> Unit = {},
): PendingIntent =
PendingIntent.getActivity(this, requestCode, intent<T>(), flags)
PendingIntent.getActivity(this, requestCode, intent<T>().apply(block), (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0) or flags)
val Context.isIgnoringBatteryOptimizations: Boolean
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {