remove also LongLivedShortcuts

This commit is contained in:
Philipp Neumann 2021-10-05 13:22:31 +02:00
parent 214deaa474
commit 95247f8b10

View file

@ -75,7 +75,11 @@ class ShortcutsHandler @Inject constructor(
return
}
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
// according to https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat#removeLongLivedShortcuts(android.content.Context,%20java.util.List%3Cjava.lang.String%3E)
// removeLongLivedShortcuts for API 29 and lower should behave like removeDynamicShortcuts(Context, List)
// getDynamicShortcuts: returns all dynamic shortcuts from the app.
val shortcuts = ShortcutManagerCompat.getDynamicShortcuts(context).map { it.id }
ShortcutManagerCompat.removeLongLivedShortcuts(context, shortcuts)
// We can only disabled pinned shortcuts with the API, but at least it will prevent the crash
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {