Do a check for shortcut host permissions before pinning a shortcut

This commit is contained in:
Ensar Sarajčić 2023-09-22 10:45:51 +02:00
parent 2614be4f42
commit 545c424bd5
1 changed files with 8 additions and 6 deletions

View File

@ -233,6 +233,7 @@ class MainActivity : SimpleActivity(), FlingListener {
REQUEST_CREATE_SHORTCUT -> {
if (resultCode == Activity.RESULT_OK && resultData != null) {
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
if (launcherApps.hasShortcutHostPermission()) {
val item = launcherApps.getPinItemRequest(resultData)
if (item.accept()) {
val shortcutId = item.shortcutInfo?.id!!
@ -244,6 +245,7 @@ class MainActivity : SimpleActivity(), FlingListener {
}
}
}
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)