ShortcutInfoCompat
class ShortcutInfoCompat
Helper for accessing features in ShortcutInfo.
Summary
Nested types |
|---|
|
Builder class for |
Constants |
|
|---|---|
const Int |
SURFACE_LAUNCHER = 1Indicates 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 |
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 |
getId()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 |
Long |
Last time when any of the fields was updated. |
LocusIdCompat? |
Gets the |
CharSequence? |
Return the long description of a shortcut. |
String |
Return the package name of the publisher app. |
Int |
getRank()Returns the rank of the shortcut set with |
CharSequence |
Return the short description of a shortcut. |
UserHandle? |
|
Boolean |
Return whether a shortcut only contains "key" information only or not. |
Boolean |
isCached()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 |
Boolean |
isExcludedFromSurfaces(surface: Int)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 |
Boolean |
isPinned()Return whether a shortcut is pinned. |
ShortcutInfo! |
@RequiresApi(value = 25) |
Constants
SURFACE_LAUNCHER
const val SURFACE_LAUNCHER = 1: Int
Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.
Public functions
getActivity
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
fun getCategories(): (Mutable)Set<String!>?
Return the categories set with setCategories.
| See also | |
|---|---|
setCategories |
getDisabledMessage
fun getDisabledMessage(): CharSequence?
Return the message that should be shown when the user attempts to start a shortcut that is disabled.
| See also | |
|---|---|
setDisabledMessage |
getDisabledReason
fun getDisabledReason(): Int
Returns why a shortcut has been disabled.
getExcludedFromSurfaces
fun getExcludedFromSurfaces(): Int
Returns a bitmask of all surfaces this shortcut is excluded from.
| See also | |
|---|---|
setExcludedFromSurfaces |
getId
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
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
fun getIntents(): Array<Intent!>
Return the intent set with setIntents.
| See also | |
|---|---|
setIntents |
getLastChangedTimestamp
fun getLastChangedTimestamp(): Long
Last time when any of the fields was updated.
getLocusId
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
fun getLongLabel(): CharSequence?
Return the long description of a shortcut.
| See also | |
|---|---|
setLongLabel |
getRank
fun getRank(): Int
Returns the rank of the shortcut set with setRank.
| See also | |
|---|---|
setRank |
getShortLabel
fun getShortLabel(): CharSequence
Return the short description of a shortcut.
| See also | |
|---|---|
setShortLabel |
getUserHandle
fun getUserHandle(): UserHandle?
UserHandle on which the publisher created this shortcut.
hasKeyFieldsOnly
fun hasKeyFieldsOnly(): Boolean
Return whether a shortcut only contains "key" information only or not. If true, only the following fields are available.
isDeclaredInManifest
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.
isEnabled
fun isEnabled(): Boolean
Returns false if a shortcut is disabled with disableShortcuts.
isExcludedFromSurfaces
fun isExcludedFromSurfaces(surface: Int): Boolean
Return true if the shortcut is excluded from specified surface.
isImmutable
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.
toShortcutInfo
@RequiresApi(value = 25)
fun toShortcutInfo(): ShortcutInfo!
| Returns | |
|---|---|
ShortcutInfo! |
|