public static boolean requestPinShortcut(@NonNull final Context context,
                                             @NonNull ShortcutInfoCompat shortcut, @Nullable final IntentSender callback) {
        if (Build.VERSION.SDK_INT >= 26) {
            return context.getSystemService(ShortcutManager.class).requestPinShortcut(
                    shortcut.toShortcutInfo(), callback);
        }

        if (!isRequestPinShortcutSupported(context)) {
            return false;
        }
        Intent intent = shortcut.addToIntent(new Intent(ACTION_INSTALL_SHORTCUT));

        // If the callback is null, just send the broadcast
        if (callback == null) {
            context.sendBroadcast(intent);
            return true;
        }

        // Otherwise send the callback when the intent has successfully been dispatched.
        context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    callback.sendIntent(context, 0, null, null, null);
                } catch (IntentSender.SendIntentException e) {
                    // Ignore
                }
            }
        }, null, Activity.RESULT_OK, null, null);
        return true;
    }
Request to create a pinned shortcut.
<p>On API <= 25 it creates a legacy shortcut with the provided icon, label and intent. For
newer APIs it will create a {@link android.content.pm.ShortcutInfo} object which can be
updated by the app.

<p>Use {@link android.app.PendingIntent#getIntentSender()} to create a {@link IntentSender}.

@param shortcut new shortcut to pin
@param callback if not null, this intent will be sent when the shortcut is pinned
@return {@code true} if the launcher supports this feature
@see #isRequestPinShortcutSupported
@see IntentSender
@see android.app.PendingIntent#getIntentSender()
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/compat/ShortcutManagerCompat.java