From 3664159782d98052070e3d6fe0d987649c8ab228 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Thu, 13 Mar 2025 15:38:00 +0100 Subject: [PATCH] fix #116 --- .../java/de/jrpie/android/launcher/Functions.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/jrpie/android/launcher/Functions.kt b/app/src/main/java/de/jrpie/android/launcher/Functions.kt index 8f5e08d..81e58d7 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Functions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Functions.kt @@ -93,12 +93,17 @@ fun getUserFromId(userId: Int?, context: Context): UserHandle { fun removeUnusedShortcuts(context: Context) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps fun getShortcuts(profile: UserHandle): List? { - return launcherApps.getShortcuts( - ShortcutQuery().apply { - setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED) - }, - profile - ) + return try { + launcherApps.getShortcuts( + ShortcutQuery().apply { + setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED) + }, + profile + ) + } catch (e: IllegalStateException) { + // https://github.com/jrpie/launcher/issues/116 + return null + } } val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager