ShortcutInfo
public
final
class
ShortcutInfo
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.content.pm.ShortcutInfo |
Represents a "launcher shortcut" that can be published via ShortcutManager.
See also:
Summary
Nested classes | |
|---|---|
class |
ShortcutInfo.Builder
Builder class for |
Constants | |
|---|---|
String |
SHORTCUT_CATEGORY_CONVERSATION
Shortcut category for messaging related actions, such as chat. |
Inherited constants |
|---|
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 application can set to any purposes. |
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. |
CharSequence
|
getLongLabel()
Return the longer description of a shortcut. |
String
|
getPackage()
Return the package name of the publisher application. |
int
|
getRank()
"Rank" of a shortcut, which is a non-negative, sequential value that's unique for each
|
CharSequence
|
getShortLabel()
Return the shorter description of a shortcut. |
UserHandle
|
getUserHandle()
|
boolean
|
hasKeyFieldsOnly()
Return whether a shortcut only contains "key" information only or not. |
boolean
|
isDeclaredInManifest()
Return whether a shortcut is published from AndroidManifest.xml or not. |
boolean
|
isDynamic()
Return whether a shortcut is dynamic. |
boolean
|
isEnabled()
Returns |
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 | |
|---|---|
java.lang.Object
| |
android.os.Parcelable
| |
Constants
SHORTCUT_CATEGORY_CONVERSATION
String SHORTCUT_CATEGORY_CONVERSATION
Shortcut category for messaging related actions, such as chat.
Constant Value: "android.shortcut.conversation"
Fields
Public methods
describeContents
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
ComponentName getActivity ()
Return the target activity.
This has nothing to do with the activity that this shortcut will launch. Launcher applications should show the launcher icon for the returned activity alongside this shortcut.
| Returns | |
|---|---|
ComponentName |
|
See also:
getCategories
Set<String> getCategories ()
Return the shortcut's categories.
| Returns | |
|---|---|
Set<String> |
|
See also:
getDisabledMessage
CharSequence getDisabledMessage ()
Return the message that should be shown when the user attempts to start a shortcut that is disabled.
| Returns | |
|---|---|
CharSequence |
|
See also:
getExtras
PersistableBundle getExtras ()
Extras that application can set to any purposes.
| Returns | |
|---|---|
PersistableBundle |
|
See also:
getId
String getId ()
Returns the ID of a shortcut.
Shortcut IDs are unique within each publisher application 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 |
|
getIntent
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 applications 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 |
|
See also:
getIntents
Intent[] getIntents ()
Return the intent set with setIntents(Intent[]).
Launcher applications 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[] |
|
See also:
getLastChangedTimestamp
long getLastChangedTimestamp ()
Last time when any of the fields was updated.
| Returns | |
|---|---|
long |
|
getLongLabel
CharSequence getLongLabel ()
Return the longer description of a shortcut.
| Returns | |
|---|---|
CharSequence |
|
See also:
getPackage
String getPackage ()
Return the package name of the publisher application.
| Returns | |
|---|---|
String |
|
getRank
int getRank ()
"Rank" of a shortcut, which is a non-negative, sequential value that's unique for each
getActivity() for each of the two kinds, dynamic shortcuts and manifest shortcuts.
Because manifest shortcuts and dynamic shortcuts have overlapping ranks, when a launcher application shows shortcuts for an activity, it should first show the manifest shortcuts followed by the dynamic shortcuts. Within each of those categories, shortcuts should be sorted by rank in ascending order.
"Floating" shortcuts (i.e. shortcuts that are neither dynamic nor manifest) will all
have rank 0, because there's no sorting for them.
See the ShortcutManager's class javadoc for details.
| Returns | |
|---|---|
int |
|
See also:
getShortLabel
CharSequence getShortLabel ()
Return the shorter description of a shortcut.
| Returns | |
|---|---|
CharSequence |
|
See also:
getUserHandle
UserHandle getUserHandle ()
UserHandle on which the publisher created this shortcut.
| Returns | |
|---|---|
UserHandle |
|
hasKeyFieldsOnly
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
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
boolean isDeclaredInManifest ()
Return whether a shortcut is published from AndroidManifest.xml or not. If true,
it's 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 just disappear.
However, if it's pinned, it will still be alive, and isEnabled() will be
false and isImmutable() will be true.
| Returns | |
|---|---|
boolean |
|
isDynamic
boolean isDynamic ()
Return whether a shortcut is dynamic.
| Returns | |
|---|---|
boolean |
|
isEnabled
boolean isEnabled ()
Returns false if a shortcut is disabled with
disableShortcuts(List.
| Returns | |
|---|---|
boolean |
|
isImmutable
boolean isImmutable ()
Return if a shortcut is immutable, in which case it cannot be modified with any of
ShortcutManager APIs.
All manifest shortcuts are immutable. When a manifest shortcut is pinned and then
disabled because the app is upgraded and its AndroidManifest.xml no longer publishes it,
isDeclaredInManifest() returns false, but it is still immutable.
All shortcuts originally published via the ShortcutManager APIs
are all mutable.
| Returns | |
|---|---|
boolean |
|
isPinned
boolean isPinned ()
Return whether a shortcut is pinned.
| Returns | |
|---|---|
boolean |
|
toString
String toString ()
Return a string representation, intended for logging. Some fields will be retracted.
| Returns | |
|---|---|
String |
a string representation of the object. |
writeToParcel
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.
|
Classes
- ActivityInfo
- ActivityInfo.WindowLayout
- ApplicationInfo
- ApplicationInfo.DisplayNameComparator
- ComponentInfo
- ConfigurationInfo
- FeatureGroupInfo
- FeatureInfo
- InstrumentationInfo
- LabeledIntent
- LauncherActivityInfo
- LauncherApps
- LauncherApps.Callback
- LauncherApps.ShortcutQuery
- PackageInfo
- PackageInstaller
- PackageInstaller.Session
- PackageInstaller.SessionCallback
- PackageInstaller.SessionInfo
- PackageInstaller.SessionParams
- PackageItemInfo
- PackageItemInfo.DisplayNameComparator
- PackageManager
- PackageStats
- PathPermission
- PermissionGroupInfo
- PermissionInfo
- ProviderInfo
- ResolveInfo
- ResolveInfo.DisplayNameComparator
- ServiceInfo
- ShortcutInfo
- ShortcutInfo.Builder
- ShortcutManager
- Signature
Exceptions


