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 |
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 |
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 |
createFromGenericDocument(context: Context, document: GenericDocument) Convert a |
Int | |
ComponentName? |
Return the target activity. |
MutableList<Capability!> |
Return a list of |
MutableList<CapabilityParams!> |
getCapabilityParams(capability: Capability) Returns the |
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 |
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. |
LocusId? |
Gets the |
CharSequence? |
Return the long description of a shortcut. |
String |
Return the package name of the publisher app. |
Int |
getRank() "Rank" of a shortcut, which is a non-negative, sequential value that's unique for each |
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. |
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. |
String |
toString() Return a string representation, intended for logging. |
Unit |
writeToParcel(dest: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<ShortcutInfo!> |
Constants
DISABLED_REASON_APP_CHANGED
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
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
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
static val DISABLED_REASON_NOT_DISABLED: Int
Shortcut is not disabled.
Value: 0
DISABLED_REASON_OTHER_RESTORE_ISSUE
static val DISABLED_REASON_OTHER_RESTORE_ISSUE: Int
Shortcut has not been restored for unknown reason.
Value: 103
DISABLED_REASON_SIGNATURE_MISMATCH
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
static val DISABLED_REASON_UNKNOWN: Int
Shortcut is disabled for an unknown reason.
Value: 3
DISABLED_REASON_VERSION_LOWER
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
static val SHORTCUT_CATEGORY_CONVERSATION: String
Shortcut category for messaging related actions, such as chat.
Value: "android.shortcut.conversation"
SURFACE_LAUNCHER
static val SURFACE_LAUNCHER: Int
Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.
Value: 1
Public methods
createFromGenericDocument
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
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
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
fun getCapabilities(): MutableList<Capability!>
Return a list of Capability
associated with the shortcut.
Return | |
---|---|
MutableList<Capability!> |
This value cannot be null . |
getCapabilityParams
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
fun getCategories(): MutableSet<String!>?
Return the shortcut's categories.
Return | |
---|---|
MutableSet<String!>? |
This value may be null . |
getDisabledMessage
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 . |
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.
Return | |
---|---|
Int |
Value is either 0 or android.content.pm.ShortcutInfo#SURFACE_LAUNCHER |
getExtras
fun getExtras(): PersistableBundle?
Extras that the app can set for any purpose.
Return | |
---|---|
PersistableBundle? |
This value may be null . |
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 ShortcutManager
for details.
Return | |
---|---|
String |
This value cannot be null . |
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.
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
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
fun getLastChangedTimestamp(): Long
Last time when any of the fields was updated.
getLocusId
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
fun getLongLabel(): CharSequence?
Return the long description of a shortcut.
Return | |
---|---|
CharSequence? |
This value may be null . |
getPackage
fun getPackage(): String
Return the package name of the publisher app.
Return | |
---|---|
String |
This value cannot be null . |
getRank
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
fun getShortLabel(): CharSequence?
Return the short description of a shortcut.
Return | |
---|---|
CharSequence? |
This value may be null . |
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.
getId()
getPackage()
getActivity()
getLastChangedTimestamp()
isDynamic()
isPinned()
isDeclaredInManifest()
isImmutable()
isEnabled()
getUserHandle()
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.
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 android.content.pm.ShortcutManager#disableShortcuts.
isExcludedFromSurfaces
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
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.
toString
fun toString(): String
Return a string representation, intended for logging. Some fields will be retracted.
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
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 |