Android Question Create "Pinned" shortcuts?


Licensed User
Longtime User
I would like to create a "Pinned" shortcut from *within* my app. A "pinned" shortcut is a shortcut that has an icon that is separate from the app's main icon on your homescreen.

Normally you can do this using the below method:

But the above method doesn't work on Oreo (8.0+) devices as explained here:

I do NOT want to create "Dynamic" shortcuts as explained in these two posts:

So, I came across these posts on how to use the ShortcutManager to create "Pinned" shortcuts (which will ask the user for permission before placing the new shortcut on the homescreen/launcher:

if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
                final ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

                ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(context, shortcutId)
                        .setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
                        .setIntent(new Intent(context, MainActivity.class).setAction(Intent.ACTION_MAIN))
                shortcutManager.requestPinShortcut(pinShortcutInfo, null);
But, I am not very good at converting java code to work in B4A.

Any help to get this working would be greatly appreciated :)
Last edited: