ShortcutInfoCompat
public
class
ShortcutInfoCompat
extends Object
java.lang.Object | |
↳ | androidx.core.content.pm.ShortcutInfoCompat |
Helper for accessing features in ShortcutInfo
.
Summary
Nested classes | |
---|---|
class |
ShortcutInfoCompat.Builder
Builder class for |
Public methods | |
---|---|
ComponentName
|
getActivity()
Return the target activity. |
Set<String>
|
getCategories()
Return the categories set with |
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. |
PersistableBundle
|
getExtras()
|
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. |
LocusIdCompat
|
getLocusId()
Gets the |
CharSequence
|
getLongLabel()
Return the long description of a shortcut. |
String
|
getPackage()
Return the package name of the publisher app. |
int
|
getRank()
Returns the rank of the shortcut set with |
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
|
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. |
ShortcutInfo
|
toShortcutInfo()
|
Inherited methods | |
---|---|
Public methods
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 |
getCategories
public Set<String> getCategories ()
Return the categories set with ShortcutInfoCompat.Builder.setCategories(Set)
.
Returns | |
---|---|
Set<String> |
getDisabledMessage
public CharSequence getDisabledMessage ()
Return the message that should be shown when the user attempts to start a shortcut that is disabled.
Returns | |
---|---|
CharSequence |
getDisabledReason
public int getDisabledReason ()
Returns why a shortcut has been disabled.
Returns | |
---|---|
int |
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 |
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.
Returns | |
---|---|
Intent |
getIntents
public Intent[] getIntents ()
Return the intent set with ShortcutInfoCompat.Builder.setIntents(Intent[])
.
Returns | |
---|---|
Intent[] |
getLastChangedTimestamp
public long getLastChangedTimestamp ()
Last time when any of the fields was updated.
Returns | |
---|---|
long |
getLocusId
public LocusIdCompat getLocusId ()
Gets the LocusIdCompat
associated with this shortcut.
Used by the device's intelligence services to correlate objects (such as
NotificationCompat
and
ContentCaptureContext
) that are correlated.
Returns | |
---|---|
LocusIdCompat |
getLongLabel
public CharSequence getLongLabel ()
Return the long description of a shortcut.
Returns | |
---|---|
CharSequence |
getPackage
public String getPackage ()
Return the package name of the publisher app.
Returns | |
---|---|
String |
getRank
public int getRank ()
Returns the rank of the shortcut set with ShortcutInfoCompat.Builder.setRank(int)
.
Returns | |
---|---|
int |
See also:
getShortLabel
public CharSequence getShortLabel ()
Return the short description of a shortcut.
Returns | |
---|---|
CharSequence |
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()
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 isEnabled()
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
ShortcutManagerCompat.disableShortcuts(Context, List
.
Returns | |
---|---|
boolean |
isImmutable
public boolean isImmutable ()
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.
Returns | |
---|---|
boolean |
isPinned
public boolean isPinned ()
Return whether a shortcut is pinned.
Returns | |
---|---|
boolean |
toShortcutInfo
public ShortcutInfo toShortcutInfo ()
Returns | |
---|---|
ShortcutInfo |
ShortcutInfo object from this compat object.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-09-30 UTC.