Google 致力于为黑人社区推动种族平等。查看具体举措

ShortcutInfoCompat

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

Helper for accessing features in ShortcutInfo.

Summary

Nested classes
open

Builder class for ShortcutInfoCompat objects.

Public methods
open ComponentName?

Return the target activity.

open MutableSet<String!>?

Return the categories set with Builder#setCategories(Set).

open CharSequence?

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

open Int

Returns why a shortcut has been disabled.

open PersistableBundle?

open String

Returns the ID of a shortcut.

open Intent

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

open Array<Intent!>

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

open Long

Last time when any of the fields was updated.

open LocusIdCompat?

Gets the LocusIdCompat associated with this shortcut.

open CharSequence?

Return the long description of a shortcut.

open String

Return the package name of the publisher app.

open Int

Returns the rank of the shortcut set with Builder#setRank(int).

open CharSequence

Return the short description of a shortcut.

open UserHandle?

UserHandle on which the publisher created this shortcut.

open Boolean

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

open Boolean

Return whether a shortcut is cached.

open Boolean

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

open Boolean

Return whether a shortcut is dynamic.

open Boolean

Returns false if a shortcut is disabled with ShortcutManagerCompat#disableShortcuts.

open Boolean

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

open Boolean

Return whether a shortcut is pinned.

open ShortcutInfo!

Public methods

getActivity

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

getCategories

@Nullable open fun getCategories(): MutableSet<String!>?

Return the categories set with Builder#setCategories(Set).

getDisabledMessage

@Nullable open fun getDisabledMessage(): CharSequence?

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

getDisabledReason

open fun getDisabledReason(): Int

Returns why a shortcut has been disabled.

getExtras

@Nullable open fun getExtras(): PersistableBundle?

getId

@NonNull open 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

@NonNull open 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.

getIntents

@NonNull open fun getIntents(): Array<Intent!>

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

getLastChangedTimestamp

open fun getLastChangedTimestamp(): Long

Last time when any of the fields was updated.

getLocusId

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

@Nullable open fun getLongLabel(): CharSequence?

Return the long description of a shortcut.

getPackage

@NonNull open fun getPackage(): String

Return the package name of the publisher app.

getRank

open fun getRank(): Int

Returns the rank of the shortcut set with Builder#setRank(int).

getShortLabel

@NonNull open fun getShortLabel(): CharSequence

Return the short description of a shortcut.

getUserHandle

@Nullable open fun getUserHandle(): UserHandle?

UserHandle on which the publisher created this shortcut.

hasKeyFieldsOnly

open fun hasKeyFieldsOnly(): Boolean

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

isCached

open fun isCached(): Boolean

Return whether a shortcut is cached.

isDeclaredInManifest

open 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 isEnabled() will be true.

isDynamic

open fun isDynamic(): Boolean

Return whether a shortcut is dynamic.

isEnabled

open fun isEnabled(): Boolean

Returns false if a shortcut is disabled with ShortcutManagerCompat#disableShortcuts.

isImmutable

open 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

open fun isPinned(): Boolean

Return whether a shortcut is pinned.

toShortcutInfo

@RequiresApi(25) open fun toShortcutInfo(): ShortcutInfo!
Return
ShortcutInfo! ShortcutInfo object from this compat object.