Android Question Add pinned shortcut usage?

tsteward

Well-Known Member
Licensed User
Longtime User
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
 
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))


Doesn't work gives this error:
java.lang.RuntimeException: Method: getShortcuts not found in: androidx.core.content.pm.ShortcutManagerCompat
 
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
 
Upvote 0

Similar Threads

Back
Top