Skip to content

Commit

Permalink
remove also LongLivedShortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
VWPhilipp committed Oct 5, 2021
1 parent 5bfa050 commit 89e82b9
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 89e82b9

Please sign in to comment.