ShortcutManagerCompat

open class ShortcutManagerCompat
kotlin.Any
   ↳ androidx.core.content.pm.ShortcutManagerCompat

Helper for accessing features in android.content.pm.ShortcutManager.

Summary

Public methods
open static Boolean

open static Boolean
requestPinShortcut(context: Context, shortcut: ShortcutInfoCompat, callback: IntentSender?)

Request to create a pinned shortcut.

open static Intent

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

Public methods

isRequestPinShortcutSupported

open static fun isRequestPinShortcutSupported(context: Context): Boolean
Return
Boolean: true if the launcher supports #requestPinShortcut, false otherwise

requestPinShortcut

open static fun requestPinShortcut(context: Context, shortcut: ShortcutInfoCompat, callback: IntentSender?): Boolean

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 android.content.pm.ShortcutInfo object which can be updated by the app.

Use android.app.PendingIntent#getIntentSender() to create a IntentSender.

Parameters
shortcut Context: new shortcut to pin
callback Context: if not null, this intent will be sent when the shortcut is pinned
Return
Boolean: true if the launcher supports this feature

createShortcutResultIntent

open static fun createShortcutResultIntent(context: Context, shortcut: ShortcutInfoCompat): Intent

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
shortcut Context: new shortcut to pin
Return
Intent: the intent that should be set as the result for the calling activity