Created
April 27, 2021 06:48
-
-
Save libliboom/c6e3f761e9956b3860552fb86b6fca94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Context.createNotificationSettingsIntent() = | |
when { | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> { | |
Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS).apply { | |
putExtra(Settings.EXTRA_APP_PACKAGE, packageName) | |
} | |
} | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP -> { | |
Intent().apply { | |
action = "android.settings.APP_NOTIFICATION_SETTINGS" | |
putExtra("app_package", packageName) | |
putExtra("app_uid", applicationInfo.uid) | |
} | |
} | |
else -> { | |
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { | |
data = Uri.parse("package:$packageName") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment