ShortcutInfo
  public
  
  final
  
  class
  ShortcutInfo
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.content.pm.ShortcutInfo | 
Represents a shortcut that can be published via ShortcutManager.
See also:
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | ShortcutInfo.BuilderBuilder class for  | 
| Constants | |
|---|---|
| int | DISABLED_REASON_APP_CHANGEDShortcut has been disabled due to changes to the publisher app. | 
| int | DISABLED_REASON_BACKUP_NOT_SUPPORTEDShortcut has not been restored because the publisher app does not support backup and restore. | 
| int | DISABLED_REASON_BY_APPShortcut has been disabled by the publisher app with the
  | 
| int | DISABLED_REASON_NOT_DISABLEDShortcut is not disabled. | 
| int | DISABLED_REASON_OTHER_RESTORE_ISSUEShortcut has not been restored for unknown reason. | 
| int | DISABLED_REASON_SIGNATURE_MISMATCHShortcut has not been restored because the publisher app's signature has changed. | 
| int | DISABLED_REASON_UNKNOWNShortcut is disabled for an unknown reason. | 
| int | DISABLED_REASON_VERSION_LOWERShortcut has been restored from the previous device, but the publisher app on the current device is of a lower version. | 
| String | SHORTCUT_CATEGORY_CONVERSATIONShortcut category for messaging related actions, such as chat. | 
| int | SURFACE_LAUNCHERIndicates system surfaces managed by a launcher app. | 
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<ShortcutInfo> | CREATOR
 | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        ShortcutInfo | 
      createFromGenericDocument(Context context, GenericDocument document)
      Convert a  | 
| 
        
        
        
        
        
        int | 
      describeContents()
      Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | 
| 
        
        
        
        
        
        ComponentName | 
      getActivity()
      Return the target activity. | 
| 
        
        
        
        
        
        List<Capability> | 
      getCapabilities()
      Return a list of  | 
| 
        
        
        
        
        
        List<CapabilityParams> | 
      getCapabilityParams(Capability capability)
      Returns the  | 
| 
        
        
        
        
        
        Set<String> | 
      getCategories()
      Return the shortcut's categories. | 
| 
        
        
        
        
        
        CharSequence | 
      getDisabledMessage()
      Return the message that should be shown when the user attempts to start a shortcut that is disabled. | 
| 
        
        
        
        
        
        int | 
      getDisabledReason()
      Returns why a shortcut has been disabled. | 
| 
        
        
        
        
        
        int | 
      getExcludedFromSurfaces()
      Returns a bitmask of all surfaces this shortcut is excluded from. | 
| 
        
        
        
        
        
        PersistableBundle | 
      getExtras()
      Extras that the app can set for any purpose. | 
| 
        
        
        
        
        
        String | 
      getId()
      Returns the ID of a shortcut. | 
| 
        
        
        
        
        
        Intent | 
      getIntent()
      Returns the intent that is executed when the user selects this shortcut. | 
| 
        
        
        
        
        
        Intent[] | 
      getIntents()
      Return the intent set with  | 
| 
        
        
        
        
        
        long | 
      getLastChangedTimestamp()
      Last time when any of the fields was updated. | 
| 
        
        
        
        
        
        LocusId | 
      getLocusId()
      Gets the  | 
| 
        
        
        
        
        
        CharSequence | 
      getLongLabel()
      Return the long description of a shortcut. | 
| 
        
        
        
        
        
        String | 
      getPackage()
      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 | 
      getShortLabel()
      Return the short description of a shortcut. | 
| 
        
        
        
        
        
        UserHandle | 
      getUserHandle()
      
 | 
| 
        
        
        
        
        
        boolean | 
      hasKeyFieldsOnly()
      Return whether a shortcut only contains "key" information only or not. | 
| 
        
        
        
        
        
        boolean | 
      isCached()
      Return whether a shortcut is cached. | 
| 
        
        
        
        
        
        boolean | 
      isDeclaredInManifest()
      Return whether a shortcut is static; that is, whether a shortcut is published from AndroidManifest.xml. | 
| 
        
        
        
        
        
        boolean | 
      isDynamic()
      Return whether a shortcut is dynamic. | 
| 
        
        
        
        
        
        boolean | 
      isEnabled()
      Returns  | 
| 
        
        
        
        
        
        boolean | 
      isExcludedFromSurfaces(int surface)
      Return true if the shortcut is excluded from specified surface. | 
| 
        
        
        
        
        
        boolean | 
      isImmutable()
      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. | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel dest, int flags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
Constants
DISABLED_REASON_APP_CHANGED
public static final int DISABLED_REASON_APP_CHANGED
Shortcut has been disabled due to changes to the publisher app. (e.g. a manifest shortcut no longer exists.)
Constant Value: 2 (0x00000002)
DISABLED_REASON_BACKUP_NOT_SUPPORTED
public static final int DISABLED_REASON_BACKUP_NOT_SUPPORTED
Shortcut has not been restored because the publisher app does not support backup and restore.
Constant Value: 101 (0x00000065)
DISABLED_REASON_BY_APP
public static final int DISABLED_REASON_BY_APP
Shortcut has been disabled by the publisher app with the
 ShortcutManager.disableShortcuts(List) API.
Constant Value: 1 (0x00000001)
DISABLED_REASON_NOT_DISABLED
public static final int DISABLED_REASON_NOT_DISABLED
Shortcut is not disabled.
Constant Value: 0 (0x00000000)
DISABLED_REASON_OTHER_RESTORE_ISSUE
public static final int DISABLED_REASON_OTHER_RESTORE_ISSUE
Shortcut has not been restored for unknown reason.
Constant Value: 103 (0x00000067)
DISABLED_REASON_SIGNATURE_MISMATCH
public static final int DISABLED_REASON_SIGNATURE_MISMATCH
Shortcut has not been restored because the publisher app's signature has changed.
Constant Value: 102 (0x00000066)
DISABLED_REASON_UNKNOWN
public static final int DISABLED_REASON_UNKNOWN
Shortcut is disabled for an unknown reason.
Constant Value: 3 (0x00000003)
DISABLED_REASON_VERSION_LOWER
public static final int DISABLED_REASON_VERSION_LOWER
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.
Constant Value: 100 (0x00000064)
SHORTCUT_CATEGORY_CONVERSATION
public static final String SHORTCUT_CATEGORY_CONVERSATION
Shortcut category for messaging related actions, such as chat.
Constant Value: "android.shortcut.conversation"
SURFACE_LAUNCHER
public static final int SURFACE_LAUNCHER
Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.
Constant Value: 1 (0x00000001)
Fields
Public methods
createFromGenericDocument
public static ShortcutInfo createFromGenericDocument (Context context, GenericDocument document)
Convert a GenericDocument into a ShortcutInfo.
| Parameters | |
|---|---|
| context | Context: Client context
 This value cannot benull. | 
| document | GenericDocument: An instance ofGenericDocumentthat represents the shortcut.
 This value cannot benull. | 
| Returns | |
|---|---|
| ShortcutInfo | This value cannot be null. | 
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
 instance's marshaled representation. For example, if the object will
 include a file descriptor in the output of writeToParcel(android.os.Parcel, int),
 the return value of this method must include the
 CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
| int | a bitmask indicating the set of special object types marshaled
 by this Parcelable object instance.
 Value is either 0orCONTENTS_FILE_DESCRIPTOR | 
getActivity
public 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.
| Returns | |
|---|---|
| ComponentName | This value may be null. | 
getCapabilities
public List<Capability> getCapabilities ()
Return a list of Capability associated with the shortcut.
| Returns | |
|---|---|
| List<Capability> | This value cannot be null. | 
getCapabilityParams
public List<CapabilityParams> getCapabilityParams (Capability capability)
Returns the CapabilityParams in associated with given capability.
| Parameters | |
|---|---|
| capability | Capability:Capabilityassociated with the shortcut.
 This value cannot benull. | 
| Returns | |
|---|---|
| List<CapabilityParams> | This value cannot be null. | 
getCategories
public Set<String> getCategories ()
Return the shortcut's categories.
| Returns | |
|---|---|
| Set<String> | This value may be null. | 
See also:
getDisabledMessage
public CharSequence getDisabledMessage ()
Return the message that should be shown when the user attempts to start a shortcut that is disabled.
| Returns | |
|---|---|
| CharSequence | This value may be null. | 
getDisabledReason
public int getDisabledReason ()
Returns why a shortcut has been disabled.
getExcludedFromSurfaces
public int getExcludedFromSurfaces ()
Returns a bitmask of all surfaces this shortcut is excluded from.
| Returns | |
|---|---|
| int | Value is either 0orSURFACE_LAUNCHER | 
getExtras
public PersistableBundle getExtras ()
Extras that the app can set for any purpose.
| Returns | |
|---|---|
| PersistableBundle | This value may be null. | 
getId
public 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 ShortcutManager for details.
| Returns | |
|---|---|
| String | This value cannot be null. | 
getIntent
public 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.
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 LauncherApps.startShortcut.
| Returns | |
|---|---|
| Intent | |
See also:
getIntents
public Intent[] getIntents ()
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 LauncherApps.startShortcut.
| Returns | |
|---|---|
| Intent[] | |
getLastChangedTimestamp
public long getLastChangedTimestamp ()
Last time when any of the fields was updated.
| Returns | |
|---|---|
| long | |
getLocusId
public LocusId getLocusId ()
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.
| Returns | |
|---|---|
| LocusId | This value may be null. | 
getLongLabel
public CharSequence getLongLabel ()
Return the long description of a shortcut.
| Returns | |
|---|---|
| CharSequence | This value may be null. | 
getPackage
public String getPackage ()
Return the package name of the publisher app.
| Returns | |
|---|---|
| String | This value cannot be null. | 
getRank
public int getRank ()
"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.
| Returns | |
|---|---|
| int | |
See also:
getShortLabel
public CharSequence getShortLabel ()
Return the short description of a shortcut.
| Returns | |
|---|---|
| CharSequence | This value may be null. | 
getUserHandle
public UserHandle getUserHandle ()
UserHandle on which the publisher created this shortcut.
| Returns | |
|---|---|
| UserHandle | |
hasKeyFieldsOnly
public boolean hasKeyFieldsOnly ()
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.
| Returns | |
|---|---|
| boolean | |
isCached
public boolean isCached ()
Return whether a shortcut is cached.
| Returns | |
|---|---|
| boolean | |
isDeclaredInManifest
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.
| Returns | |
|---|---|
| boolean | |
isDynamic
public boolean isDynamic ()
Return whether a shortcut is dynamic.
| Returns | |
|---|---|
| boolean | |
isEnabled
public boolean isEnabled ()
Returns false if a shortcut is disabled with
 ShortcutManager.disableShortcuts.
| Returns | |
|---|---|
| boolean | |
isExcludedFromSurfaces
public boolean isExcludedFromSurfaces (int surface)
Return true if the shortcut is excluded from specified surface.
| Parameters | |
|---|---|
| surface | int: Value is either0orSURFACE_LAUNCHER | 
| Returns | |
|---|---|
| boolean | |
isImmutable
public boolean isImmutable ()
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.
| Returns | |
|---|---|
| boolean | |
isPinned
public boolean isPinned ()
Return whether a shortcut is pinned.
| Returns | |
|---|---|
| boolean | |
toString
public String toString ()
Return a string representation, intended for logging. Some fields will be retracted.
| Returns | |
|---|---|
| String | a string representation of the object. | 
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| dest | Parcel: The Parcel in which the object should be written.
 This value cannot benull. | 
| flags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
