ShortcutInfoCompat

Added in 1.1.0

public class ShortcutInfoCompat


Helper for accessing features in ShortcutInfo.

Summary

Nested types

Builder class for ShortcutInfoCompat objects.

Constants

static final int

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

Public methods

@Nullable ComponentName

Return the target activity.

@Nullable Set<String>

Return the categories set with setCategories.

@Nullable 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.

@Nullable PersistableBundle
@NonNull String

Returns the ID of a shortcut.

@NonNull Intent

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

@NonNull Intent[]

Return the intent set with setIntents.

long

Last time when any of the fields was updated.

@Nullable LocusIdCompat

Gets the LocusIdCompat associated with this shortcut.

@Nullable CharSequence

Return the long description of a shortcut.

@NonNull String

Return the package name of the publisher app.

int

Returns the rank of the shortcut set with setRank.

@NonNull CharSequence

Return the short description of a shortcut.

@Nullable 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.xml.

boolean

Return whether a shortcut is dynamic.

boolean

Returns false if a shortcut is disabled with disableShortcuts.

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 ShortcutManagerCompat APIs.

boolean

Return whether a shortcut is pinned.

ShortcutInfo
@RequiresApi(value = 25)
toShortcutInfo()

Constants

SURFACE_LAUNCHER

Added in 1.8.0
public static final int SURFACE_LAUNCHER = 1

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

Public methods

getActivity

Added in 1.1.0
public @Nullable ComponentName getActivity()

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.

See also
setActivity

getCategories

Added in 1.1.0
public @Nullable Set<StringgetCategories()

Return the categories set with setCategories.

See also
setCategories

getDisabledMessage

Added in 1.1.0
public @Nullable CharSequence getDisabledMessage()

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

getDisabledReason

Added in 1.5.0
public int getDisabledReason()

Returns why a shortcut has been disabled.

getExcludedFromSurfaces

Added in 1.8.0
public int getExcludedFromSurfaces()

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

getExtras

Added in 1.5.0
public @Nullable PersistableBundle getExtras()

getId

Added in 1.1.0
public @NonNull String getId()

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 android.content.pm.ShortcutManager for details.

getIntent

Added in 1.1.0
public @NonNull Intent getIntent()

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

See also
setIntent

getIntents

Added in 1.1.0
public @NonNull Intent[] getIntents()

Return the intent set with setIntents.

See also
setIntents

getLastChangedTimestamp

Added in 1.5.0
public long getLastChangedTimestamp()

Last time when any of the fields was updated.

getLocusId

Added in 1.5.0
public @Nullable LocusIdCompat getLocusId()

Gets the LocusIdCompat associated with this shortcut.

Used by the device's intelligence services to correlate objects (such as androidx.core.app.NotificationCompat and android.view.contentcapture.ContentCaptureContext) that are correlated.

getLongLabel

Added in 1.1.0
public @Nullable CharSequence getLongLabel()

Return the long description of a shortcut.

See also
setLongLabel

getPackage

Added in 1.5.0
public @NonNull String getPackage()

Return the package name of the publisher app.

getRank

Added in 1.2.0
public int getRank()

Returns the rank of the shortcut set with setRank.

See also
setRank

getShortLabel

Added in 1.1.0
public @NonNull CharSequence getShortLabel()

Return the short description of a shortcut.

See also
setShortLabel

getUserHandle

Added in 1.5.0
public @Nullable UserHandle getUserHandle()

UserHandle on which the publisher created this shortcut.

hasKeyFieldsOnly

Added in 1.5.0
public boolean hasKeyFieldsOnly()

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

isCached

Added in 1.5.0
public boolean isCached()

Return whether a shortcut is cached.

isDeclaredInManifest

Added in 1.5.0
public boolean isDeclaredInManifest()

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 1.5.0
public boolean isDynamic()

Return whether a shortcut is dynamic.

isEnabled

Added in 1.5.0
public boolean isEnabled()

Returns false if a shortcut is disabled with disableShortcuts.

isExcludedFromSurfaces

Added in 1.8.0
public boolean isExcludedFromSurfaces(int surface)

Return true if the shortcut is excluded from specified surface.

isImmutable

Added in 1.5.0
public boolean isImmutable()

Return if a shortcut is immutable, in which case it cannot be modified with any of ShortcutManagerCompat 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 1.5.0
public boolean isPinned()

Return whether a shortcut is pinned.

toShortcutInfo

Added in 1.1.0
@RequiresApi(value = 25)
public ShortcutInfo toShortcutInfo()
Returns
ShortcutInfo

ShortcutInfo object from this compat object.