ShortcutInfoCompat
public class ShortcutInfoCompat
Helper for accessing features in ShortcutInfo.
Summary
Nested types |
|---|
public class ShortcutInfoCompat.BuilderBuilder class for |
Constants |
|
|---|---|
static final int |
SURFACE_LAUNCHER = 1Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu. |
Public methods |
|
|---|---|
@Nullable ComponentName |
Return the target activity. |
@Nullable Set<String> |
Return the categories set with |
@Nullable 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. |
@Nullable PersistableBundle |
|
@NonNull String |
getId()Returns the ID of a shortcut. |
@NonNull Intent |
Returns the intent that is executed when the user selects this shortcut. |
@NonNull Intent[] |
Return the intent set with |
long |
Last time when any of the fields was updated. |
@Nullable LocusIdCompat |
Gets the |
@Nullable CharSequence |
Return the long description of a shortcut. |
@NonNull String |
Return the package name of the publisher app. |
int |
getRank()Returns the rank of the shortcut set with |
@NonNull CharSequence |
Return the short description of a shortcut. |
@Nullable 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.xml. |
boolean |
Return whether a shortcut is dynamic. |
boolean |
Returns |
boolean |
isExcludedFromSurfaces(int surface)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. |
ShortcutInfo |
@RequiresApi(value = 25) |
Constants
SURFACE_LAUNCHER
public static final int SURFACE_LAUNCHER = 1
Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.
Public methods
getActivity
public @Nullable 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.
| See also | |
|---|---|
setActivity |
getCategories
public @Nullable Set<String> getCategories()
Return the categories set with setCategories.
| See also | |
|---|---|
setCategories |
getDisabledMessage
public @Nullable CharSequence getDisabledMessage()
Return the message that should be shown when the user attempts to start a shortcut that is disabled.
| See also | |
|---|---|
setDisabledMessage |
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.
| See also | |
|---|---|
setExcludedFromSurfaces |
getId
public @NonNull 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 android.content.pm.ShortcutManager for details.
getIntent
public @NonNull 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.
| See also | |
|---|---|
setIntent |
getIntents
public @NonNull Intent[] getIntents()
Return the intent set with setIntents.
| See also | |
|---|---|
setIntents |
getLastChangedTimestamp
public long getLastChangedTimestamp()
Last time when any of the fields was updated.
getLocusId
public @Nullable LocusIdCompat getLocusId()
Gets the LocusIdCompat associated with this shortcut.
Used by the device's intelligence services to correlate objects (such as androidx.core.app.NotificationCompat and android.view.contentcapture.ContentCaptureContext) that are correlated.
getLongLabel
public @Nullable CharSequence getLongLabel()
Return the long description of a shortcut.
| See also | |
|---|---|
setLongLabel |
getPackage
public @NonNull String getPackage()
Return the package name of the publisher app.
getRank
public int getRank()
Returns the rank of the shortcut set with setRank.
| See also | |
|---|---|
setRank |
getShortLabel
public @NonNull CharSequence getShortLabel()
Return the short description of a shortcut.
| See also | |
|---|---|
setShortLabel |
getUserHandle
public @Nullable UserHandle getUserHandle()
UserHandle on which the publisher created this shortcut.
hasKeyFieldsOnly
public boolean hasKeyFieldsOnly()
Return whether a shortcut only contains "key" information only or not. If true, only the following fields are available.
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.
isEnabled
public boolean isEnabled()
Returns false if a shortcut is disabled with disableShortcuts.
isExcludedFromSurfaces
public boolean isExcludedFromSurfaces(int surface)
Return true if the shortcut is excluded from specified surface.
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.
toShortcutInfo
@RequiresApi(value = 25)
public ShortcutInfo toShortcutInfo()
| Returns | |
|---|---|
ShortcutInfo |
|