belongs to Maven artifact androidx.core:core:1.0.0-alpha1

ShortcutManagerCompat

public class ShortcutManagerCompat
extends Object

java.lang.Object
   ↳ androidx.core.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

Public methods

createShortcutResultIntent

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 Intent.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

boolean isRequestPinShortcutSupported (Context context)

Parameters
context Context

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

requestPinShortcut

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 PendingIntent.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