tsteward Well-Known Member Licensed User Longtime User Jan 2, 2021 #1 I found the Add Pin Shortcut code I have added this code to my app. in Activity_Create if first time I call RequestPinShortcut and it works great. How do I only call this if shortcut does not exist? What's the update parametre used for? Thanks probs obvious to some, looked for examples of usage but couldn't find
I found the Add Pin Shortcut code I have added this code to my app. in Activity_Create if first time I call RequestPinShortcut and it works great. How do I only call this if shortcut does not exist? What's the update parametre used for? Thanks probs obvious to some, looked for examples of usage but couldn't find
Erel B4X founder Staff member Licensed User Longtime User Jan 3, 2021 #2 You can use this (untested) code to get the current pinned shortcuts: Code: Copy Dim CurrentShortcuts As List = ShortcutManagerCompat.RunMethod("getShortcuts", Array(ctxt, 0x00000004)) tsteward said: What's the update parametre used for? Click to expand... ShortcutManagerCompat | Android Developers developer.android.com Upvote 0
You can use this (untested) code to get the current pinned shortcuts: Code: Copy Dim CurrentShortcuts As List = ShortcutManagerCompat.RunMethod("getShortcuts", Array(ctxt, 0x00000004)) tsteward said: What's the update parametre used for? Click to expand... ShortcutManagerCompat | Android Developers developer.android.com
tsteward Well-Known Member Licensed User Longtime User Jan 3, 2021 #3 Erel said: You can use this (untested) code to get the current pinned shortcuts: Code: Copy Dim CurrentShortcuts As List = ShortcutManagerCompat.RunMethod("getShortcuts", Array(ctxt, 0x00000004)) ShortcutManagerCompat | Android Developers developer.android.com Click to expand... Doesn't work gives this error: java.lang.RuntimeException: Method: getShortcuts not found in: androidx.core.content.pm.ShortcutManagerCompat Upvote 0
Erel said: You can use this (untested) code to get the current pinned shortcuts: Code: Copy Dim CurrentShortcuts As List = ShortcutManagerCompat.RunMethod("getShortcuts", Array(ctxt, 0x00000004)) ShortcutManagerCompat | Android Developers developer.android.com Click to expand... Doesn't work gives this error: java.lang.RuntimeException: Method: getShortcuts not found in: androidx.core.content.pm.ShortcutManagerCompat
Erel B4X founder Staff member Licensed User Longtime User Jan 3, 2021 #4 Seems like this method is new and isn't yet available in AndroidX stable version. You can use this code to get this information on Android 7.1+: Code: Copy Dim p As Phone If p.SdkVersion >= 25 Then Dim ShortcutManager As JavaObject = ctxt.RunMethod("getSystemService", Array("shortcut")) Dim pinned As List = ShortcutManager.RunMethod("getPinnedShortcuts", Null) Log(pinned.Size) End If Upvote 0
Seems like this method is new and isn't yet available in AndroidX stable version. You can use this code to get this information on Android 7.1+: Code: Copy Dim p As Phone If p.SdkVersion >= 25 Then Dim ShortcutManager As JavaObject = ctxt.RunMethod("getSystemService", Array("shortcut")) Dim pinned As List = ShortcutManager.RunMethod("getPinnedShortcuts", Null) Log(pinned.Size) End If