Skip to content

Most visited

Recently visited

navigation

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.Builder

Builder class for ShortcutInfo objects. 

Constants

String SHORTCUT_CATEGORY_CONVERSATION

Shortcut category for messaging related actions, such as chat.

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ShortcutInfo> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

ComponentName getActivity()

Return the target activity.

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.

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 setIntents(Intent[]).

long getLastChangedTimestamp()

Last time when any of the fields was updated.

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 getActivity() for each of the two types of shortcuts (static and dynamic).

CharSequence getShortLabel()

Return the short description of a shortcut.

UserHandle getUserHandle()

UserHandle on which the publisher created this shortcut.

boolean hasKeyFieldsOnly()

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

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 false if a shortcut is disabled with disableShortcuts(List).

boolean isImmutable()

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

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

From class java.lang.Object
From interface android.os.Parcelable

Constants

SHORTCUT_CATEGORY_CONVERSATION

added in API level 25
String SHORTCUT_CATEGORY_CONVERSATION

Shortcut category for messaging related actions, such as chat.

Constant Value: "android.shortcut.conversation"

Fields

CREATOR

added in API level 25
Creator<ShortcutInfo> CREATOR

Public methods

describeContents

added in API level 25
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(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.

getActivity

added in API level 25
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.

See also:

getCategories

added in API level 25
Set<String> getCategories ()

Return the shortcut's categories.

Returns
Set<String>

This value may be null.

See also:

getDisabledMessage

added in API level 25
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.

See also:

getExtras

added in API level 25
PersistableBundle getExtras ()

Extras that the app can set for any purpose.

Returns
PersistableBundle

This value may be null.

See also:

getId

added in API level 25
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 will never be null.

getIntent

added in API level 25
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 startShortcut(ShortcutInfo, Rect, Bundle).

Returns
Intent

This value may be null.

See also:

getIntents

added in API level 25
Intent[] getIntents ()

Return the intent set with 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 startShortcut(ShortcutInfo, Rect, Bundle).

Returns
Intent[]

This value may be null.

See also:

getLastChangedTimestamp

added in API level 25
long getLastChangedTimestamp ()

Last time when any of the fields was updated.

Returns
long

getLongLabel

added in API level 25
CharSequence getLongLabel ()

Return the long description of a shortcut.

Returns
CharSequence

This value may be null.

See also:

getPackage

added in API level 25
String getPackage ()

Return the package name of the publisher app.

Returns
String

This value will never be null.

getRank

added in API level 25
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).

Because static shortcuts and dynamic shortcuts have overlapping ranks, when a launcher app shows shortcuts for an activity, it should first show the static shortcuts, followed by the dynamic shortcuts. Within each of those categories, shortcuts should be sorted by rank in ascending order.

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

added in API level 25
CharSequence getShortLabel ()

Return the short description of a shortcut.

Returns
CharSequence

This value may be null.

See also:

getUserHandle

added in API level 25
UserHandle getUserHandle ()

UserHandle on which the publisher created this shortcut.

Returns
UserHandle

hasKeyFieldsOnly

added in API level 25
boolean hasKeyFieldsOnly ()

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

For performance reasons, shortcuts passed to onShortcutsChanged(String, List, UserHandle) as well as those returned from getShortcuts(ShortcutQuery, UserHandle) while using the FLAG_GET_KEY_FIELDS_ONLY option contain only key information.

Returns
boolean

isDeclaredInManifest

added in API level 25
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

added in API level 25
boolean isDynamic ()

Return whether a shortcut is dynamic.

Returns
boolean

isEnabled

added in API level 25
boolean isEnabled ()

Returns false if a shortcut is disabled with disableShortcuts(List).

Returns
boolean

isImmutable

added in API level 25
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

added in API level 25
boolean isPinned ()

Return whether a shortcut is pinned.

Returns
boolean

toString

added in API level 25
String toString ()

Return a string representation, intended for logging. Some fields will be retracted.

Returns
String a string representation of the object.

writeToParcel

added in API level 25
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.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.