Added in API level 25

ShortcutInfo


class ShortcutInfo : Parcelable
kotlin.Any
   ↳ android.content.pm.ShortcutInfo

Represents a shortcut that can be published via ShortcutManager.

Summary

Nested classes

Builder class for ShortcutInfo objects.

Constants
static Int

Shortcut has been disabled due to changes to the publisher app.

static Int

Shortcut has not been restored because the publisher app does not support backup and restore.

static Int

Shortcut has been disabled by the publisher app with the ShortcutManager#disableShortcuts(List) API.

static Int

Shortcut is not disabled.

static Int

Shortcut has not been restored for unknown reason.

static Int

Shortcut has not been restored because the publisher app's signature has changed.

static Int

Shortcut is disabled for an unknown reason.

static Int

Shortcut has been restored from the previous device, but the publisher app on the current device is of a lower version.

static String

Shortcut category for messaging related actions, such as chat.

static Int

Indicates system surfaces managed by a launcher app.

Inherited constants
Public methods
static ShortcutInfo

Convert a GenericDocument into a ShortcutInfo.

Int

ComponentName?

Return the target activity.

MutableList<Capability!>

Return a list of Capability associated with the shortcut.

MutableList<CapabilityParams!>

Returns the CapabilityParams in associated with given capability.

MutableSet<String!>?

Return the shortcut's categories.

CharSequence?

Return the message that should be shown when the user attempts to start a shortcut that is disabled.

Int

Returns why a shortcut has been disabled.

Int

Returns a bitmask of all surfaces this shortcut is excluded from.

PersistableBundle?

Extras that the app can set for any purpose.

String

Returns the ID of a shortcut.

Intent?

Returns the intent that is executed when the user selects this shortcut.

Array<Intent!>?

Return the intent set with Builder#setIntents(Intent[]).

Long

Last time when any of the fields was updated.

LocusId?

Gets the LocusId associated with this shortcut.

CharSequence?

Return the long description of a shortcut.

String

Return the package name of the publisher app.

Int

"Rank" of a shortcut, which is a non-negative, sequential value that's unique for each getActivity for each of the two types of shortcuts (static and dynamic).

CharSequence?

Return the short description of a shortcut.

UserHandle!

UserHandle on which the publisher created this shortcut.

Boolean

Return whether a shortcut only contains "key" information only or not.

Boolean

Return whether a shortcut is cached.

Boolean

Return whether a shortcut is static; that is, whether a shortcut is published from AndroidManifest.

Boolean

Return whether a shortcut is dynamic.

Boolean

Returns false if a shortcut is disabled with android.

Boolean

Return true if the shortcut is excluded from specified surface.

Boolean

Return if a shortcut is immutable, in which case it cannot be modified with any of ShortcutManager APIs.

Boolean

Return whether a shortcut is pinned.

String

Return a string representation, intended for logging.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<ShortcutInfo!>

Constants

DISABLED_REASON_APP_CHANGED

Added in API level 28
static val DISABLED_REASON_APP_CHANGED: Int

Shortcut has been disabled due to changes to the publisher app. (e.g. a manifest shortcut no longer exists.)

Value: 2

DISABLED_REASON_BACKUP_NOT_SUPPORTED

Added in API level 28
static val DISABLED_REASON_BACKUP_NOT_SUPPORTED: Int

Shortcut has not been restored because the publisher app does not support backup and restore.

Value: 101

DISABLED_REASON_BY_APP

Added in API level 28
static val DISABLED_REASON_BY_APP: Int

Shortcut has been disabled by the publisher app with the ShortcutManager#disableShortcuts(List) API.

Value: 1

DISABLED_REASON_NOT_DISABLED

Added in API level 28
static val DISABLED_REASON_NOT_DISABLED: Int

Shortcut is not disabled.

Value: 0

DISABLED_REASON_OTHER_RESTORE_ISSUE

Added in API level 28
static val DISABLED_REASON_OTHER_RESTORE_ISSUE: Int

Shortcut has not been restored for unknown reason.

Value: 103

DISABLED_REASON_SIGNATURE_MISMATCH

Added in API level 28
static val DISABLED_REASON_SIGNATURE_MISMATCH: Int

Shortcut has not been restored because the publisher app's signature has changed.

Value: 102

DISABLED_REASON_UNKNOWN

Added in API level 28
static val DISABLED_REASON_UNKNOWN: Int

Shortcut is disabled for an unknown reason.

Value: 3

DISABLED_REASON_VERSION_LOWER

Added in API level 28
static val DISABLED_REASON_VERSION_LOWER: Int

Shortcut has been restored from the previous device, but the publisher app on the current device is of a lower version. The shortcut will not be usable until the app is upgraded to the same version or higher.

Value: 100

SHORTCUT_CATEGORY_CONVERSATION

Added in API level 25
static val SHORTCUT_CATEGORY_CONVERSATION: String

Shortcut category for messaging related actions, such as chat.

Value: "android.shortcut.conversation"

SURFACE_LAUNCHER

Added in API level 33
static val SURFACE_LAUNCHER: Int

Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.

Value: 1

Public methods

createFromGenericDocument

Added in API level 33
static fun createFromGenericDocument(
    context: Context,
    document: GenericDocument
): ShortcutInfo

Convert a GenericDocument into a ShortcutInfo.

Parameters
context Context: Client context This value cannot be null.
document GenericDocument: An instance of GenericDocument that represents the shortcut. This value cannot be null.
Return
ShortcutInfo This value cannot be null.

describeContents

Added in API level 25
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getActivity

Added in API level 25
fun getActivity(): ComponentName?

Return the target activity.

This has nothing to do with the activity that this shortcut will launch. Launcher apps should show the launcher icon for the returned activity alongside this shortcut.

Return
ComponentName? This value may be null.

getCapabilities

Added in API level 33
fun getCapabilities(): MutableList<Capability!>

Return a list of Capability associated with the shortcut.

Return
MutableList<Capability!> This value cannot be null.

getCapabilityParams

Added in API level 33
fun getCapabilityParams(capability: Capability): MutableList<CapabilityParams!>

Returns the CapabilityParams in associated with given capability.

Parameters
capability Capability: Capability associated with the shortcut. This value cannot be null.
Return
MutableList<CapabilityParams!> This value cannot be null.

getCategories

Added in API level 25
fun getCategories(): MutableSet<String!>?

Return the shortcut's categories.

Return
MutableSet<String!>? This value may be null.

getDisabledMessage

Added in API level 25
fun getDisabledMessage(): CharSequence?

Return the message that should be shown when the user attempts to start a shortcut that is disabled.

Return
CharSequence? This value may be null.

getExcludedFromSurfaces

Added in API level 33
fun getExcludedFromSurfaces(): Int

Returns a bitmask of all surfaces this shortcut is excluded from.

Return
Int Value is either 0 or android.content.pm.ShortcutInfo#SURFACE_LAUNCHER

getExtras

Added in API level 25
fun getExtras(): PersistableBundle?

Extras that the app can set for any purpose.

Return
PersistableBundle? This value may be null.

getId

Added in API level 25
fun getId(): String

Returns the ID of a shortcut.

Shortcut IDs are unique within each publisher app and must be stable across devices so that shortcuts will still be valid when restored on a different device. See ShortcutManager for details.

Return
String This value cannot be null.

getIntent

Added in API level 25
fun getIntent(): Intent?

Returns the intent that is executed when the user selects this shortcut. If setIntents() was used, then return the last intent in the array.

Launcher apps cannot see the intent. If a ShortcutInfo is obtained via LauncherApps, then this method will always return null. Launchers can only start a shortcut intent with android.content.pm.LauncherApps#startShortcut.

getIntents

Added in API level 25
fun getIntents(): Array<Intent!>?

Return the intent set with Builder#setIntents(Intent[]).

Launcher apps cannot see the intents. If a ShortcutInfo is obtained via LauncherApps, then this method will always return null. Launchers can only start a shortcut intent with android.content.pm.LauncherApps#startShortcut.

getLastChangedTimestamp

Added in API level 25
fun getLastChangedTimestamp(): Long

Last time when any of the fields was updated.

getLocusId

Added in API level 29
fun getLocusId(): LocusId?

Gets the LocusId associated with this shortcut.

Used by the device's intelligence services to correlate objects (such as Notification and ContentCaptureContext) that are correlated.

Return
LocusId? This value may be null.

getLongLabel

Added in API level 25
fun getLongLabel(): CharSequence?

Return the long description of a shortcut.

Return
CharSequence? This value may be null.

getPackage

Added in API level 25
fun getPackage(): String

Return the package name of the publisher app.

Return
String This value cannot be null.

getRank

Added in API level 25
fun getRank(): Int

"Rank" of a shortcut, which is a non-negative, sequential value that's unique for each getActivity for each of the two types of shortcuts (static and dynamic).

Floating shortcuts, or shortcuts that are neither static nor dynamic, will all have rank 0, because they aren't sorted. See the ShortcutManager's class javadoc for details.

getShortLabel

Added in API level 25
fun getShortLabel(): CharSequence?

Return the short description of a shortcut.

Return
CharSequence? This value may be null.

getUserHandle

Added in API level 25
fun getUserHandle(): UserHandle!

UserHandle on which the publisher created this shortcut.

hasKeyFieldsOnly

Added in API level 25
fun hasKeyFieldsOnly(): Boolean

Return whether a shortcut only contains "key" information only or not. If true, only the following fields are available.

For performance reasons, shortcuts passed to LauncherApps.Callback#onShortcutsChanged(String, List, UserHandle) as well as those returned from LauncherApps#getShortcuts(ShortcutQuery, UserHandle) while using the ShortcutQuery#FLAG_GET_KEY_FIELDS_ONLY option contain only key information.

isCached

Added in API level 30
fun isCached(): Boolean

Return whether a shortcut is cached.

isDeclaredInManifest

Added in API level 25
fun isDeclaredInManifest(): Boolean

Return whether a shortcut is static; that is, whether a shortcut is published from AndroidManifest.xml. If true, the shortcut is also isImmutable().

When an app is upgraded and a shortcut is no longer published from AndroidManifest.xml, this will be set to false. If the shortcut is not pinned, then it'll disappear. However, if it's pinned, it will still be visible, isEnabled() will be false and isImmutable() will be true.

isDynamic

Added in API level 25
fun isDynamic(): Boolean

Return whether a shortcut is dynamic.

isEnabled

Added in API level 25
fun isEnabled(): Boolean

Returns false if a shortcut is disabled with android.content.pm.ShortcutManager#disableShortcuts.

isExcludedFromSurfaces

Added in API level 33
fun isExcludedFromSurfaces(surface: Int): Boolean

Return true if the shortcut is excluded from specified surface.

Parameters
surface Int: Value is either 0 or android.content.pm.ShortcutInfo#SURFACE_LAUNCHER

isImmutable

Added in API level 25
fun isImmutable(): Boolean

Return if a shortcut is immutable, in which case it cannot be modified with any of ShortcutManager APIs.

All static shortcuts are immutable. When a static shortcut is pinned and is then disabled because it doesn't appear in AndroidManifest.xml for a newer version of the app, isDeclaredInManifest() returns false, but the shortcut is still immutable.

All shortcuts originally published via the ShortcutManager APIs are all mutable.

isPinned

Added in API level 25
fun isPinned(): Boolean

Return whether a shortcut is pinned.

toString

Added in API level 25
fun toString(): String

Return a string representation, intended for logging. Some fields will be retracted.

Return
String a string representation of the object.

writeToParcel

Added in API level 25
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 25
static val CREATOR: Parcelable.Creator<ShortcutInfo!>