ShortcutInfoCompat

Added in 1.1.0

class ShortcutInfoCompat


Helper for accessing features in ShortcutInfo.

Summary

Nested types

Builder class for ShortcutInfoCompat objects.

Constants

const Int

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

Public functions

ComponentName?

Return the target activity.

(Mutable)Set<String!>?

Return the categories set with setCategories.

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?
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 setIntents.

Long

Last time when any of the fields was updated.

LocusIdCompat?

Gets the LocusIdCompat associated with this shortcut.

CharSequence?

Return the long description of a shortcut.

String

Return the package name of the publisher app.

Int

Returns the rank of the shortcut set with setRank.

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.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
const val SURFACE_LAUNCHER = 1: Int

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

Public functions

getActivity

Added in 1.1.0
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.

See also
setActivity

getCategories

Added in 1.1.0
fun getCategories(): (Mutable)Set<String!>?

Return the categories set with setCategories.

See also
setCategories

getDisabledMessage

Added in 1.1.0
fun getDisabledMessage(): CharSequence?

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

getDisabledReason

Added in 1.5.0
fun getDisabledReason(): Int

Returns why a shortcut has been disabled.

getExcludedFromSurfaces

Added in 1.8.0
fun getExcludedFromSurfaces(): Int

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

getExtras

Added in 1.5.0
fun getExtras(): PersistableBundle?

getId

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

getIntent

Added in 1.1.0
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.

See also
setIntent

getIntents

Added in 1.1.0
fun getIntents(): Array<Intent!>

Return the intent set with setIntents.

See also
setIntents

getLastChangedTimestamp

Added in 1.5.0
fun getLastChangedTimestamp(): Long

Last time when any of the fields was updated.

getLocusId

Added in 1.5.0
fun getLocusId(): LocusIdCompat?

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
fun getLongLabel(): CharSequence?

Return the long description of a shortcut.

See also
setLongLabel

getPackage

Added in 1.5.0
fun getPackage(): String

Return the package name of the publisher app.

getRank

Added in 1.2.0
fun getRank(): Int

Returns the rank of the shortcut set with setRank.

See also
setRank

getShortLabel

Added in 1.1.0
fun getShortLabel(): CharSequence

Return the short description of a shortcut.

See also
setShortLabel

getUserHandle

Added in 1.5.0
fun getUserHandle(): UserHandle?

UserHandle on which the publisher created this shortcut.

hasKeyFieldsOnly

Added in 1.5.0
fun hasKeyFieldsOnly(): Boolean

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
fun isCached(): Boolean

Return whether a shortcut is cached.

isDeclaredInManifest

Added in 1.5.0
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 1.5.0
fun isDynamic(): Boolean

Return whether a shortcut is dynamic.

isEnabled

Added in 1.5.0
fun isEnabled(): Boolean

Returns false if a shortcut is disabled with disableShortcuts.

isExcludedFromSurfaces

Added in 1.8.0
fun isExcludedFromSurfaces(surface: Int): Boolean

Return true if the shortcut is excluded from specified surface.

isImmutable

Added in 1.5.0
fun isImmutable(): Boolean

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
fun isPinned(): Boolean

Return whether a shortcut is pinned.

toShortcutInfo

Added in 1.1.0
@RequiresApi(value = 25)
fun toShortcutInfo(): ShortcutInfo!
Returns
ShortcutInfo!

ShortcutInfo object from this compat object.