lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey
added in version 26.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

ShortcutManagerCompat

public class ShortcutManagerCompat
extends Object

java.lang.Object
   ↳ android.support.v4.content.pm.ShortcutManagerCompat


Helper for accessing features in ShortcutManager.

Summary

Public methods

static Intent createShortcutResultIntent(Context context, ShortcutInfoCompat shortcut)

Returns an Intent which can be used by the launcher to pin shortcut.

static boolean isRequestPinShortcutSupported(Context context)
static boolean requestPinShortcut(Context context, ShortcutInfoCompat shortcut, IntentSender callback)

Request to create a pinned shortcut.

Inherited methods

From class java.lang.Object

Public methods

createShortcutResultIntent

added in version 26.1.0
Intent createShortcutResultIntent (Context context, 
                ShortcutInfoCompat shortcut)

Returns an Intent which can be used by the launcher to pin shortcut.

This should be used by an Activity to set result in response to ACTION_CREATE_SHORTCUT.

Parameters
context Context

shortcut ShortcutInfoCompat: new shortcut to pin

Returns
Intent the intent that should be set as the result for the calling activity

isRequestPinShortcutSupported

added in version 26.1.0
boolean isRequestPinShortcutSupported (Context context)

Parameters
context Context

Returns
boolean true if the launcher supports requestPinShortcut(Context, ShortcutInfoCompat, IntentSender), false otherwise

requestPinShortcut

added in version 26.1.0
boolean requestPinShortcut (Context context, 
                ShortcutInfoCompat shortcut, 
                IntentSender callback)

Request to create a pinned shortcut.

On API <= 25 it creates a legacy shortcut with the provided icon, label and intent. For newer APIs it will create a ShortcutInfo object which can be updated by the app.

Use getIntentSender() to create a IntentSender.

Parameters
context Context

shortcut ShortcutInfoCompat: new shortcut to pin

callback IntentSender: if not null, this intent will be sent when the shortcut is pinned

Returns
boolean true if the launcher supports this feature