# ShortcutInfoCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/content/pm/ShortcutInfoCompat.java+class:androidx.core.content.pm.ShortcutInfoCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public class ShortcutInfoCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder` Builder class for `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat` objects. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#SURFACE_LAUNCHER() = 1` Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/ComponentName.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getActivity()()` Return the target activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getCategories()()` Return the categories set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setCategories(java.util.Set<java.lang.String>)`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getDisabledMessage()()` Return the message that should be shown when the user attempts to start a shortcut that is disabled. |
| `int` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getDisabledReason()()` Returns why a shortcut has been disabled. |
| `int` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getExcludedFromSurfaces()()` Returns a bitmask of all surfaces this shortcut is excluded from. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/PersistableBundle.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getExtras()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getId()()` Returns the ID of a shortcut. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getIntent()()` Returns the intent that is executed when the user selects this shortcut. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Intent[]` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getIntents()()` Return the intent set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setIntents(android.content.Intent[])`. |
| `long` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getLastChangedTimestamp()()` Last time when any of the fields was updated. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/content/LocusIdCompat` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getLocusId()()` Gets the `https://developer.android.com/reference/androidx/core/content/LocusIdCompat` associated with this shortcut. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getLongLabel()()` Return the long description of a shortcut. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getPackage()()` Return the package name of the publisher app. |
| `int` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getRank()()` Returns the rank of the shortcut set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setRank(int)`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getShortLabel()()` Return the short description of a shortcut. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/UserHandle.html` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getUserHandle()()` `https://developer.android.com/reference/android/os/UserHandle.html` on which the publisher created this shortcut. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#hasKeyFieldsOnly()()` Return whether a shortcut only contains "key" information only or not. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isCached()()` Return whether a shortcut is cached. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isDeclaredInManifest()()` Return whether a shortcut is static; that is, whether a shortcut is published from AndroidManifest.xml. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isDynamic()()` Return whether a shortcut is dynamic. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isEnabled()()` Returns `false` if a shortcut is disabled with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat#disableShortcuts(android.content.Context,java.util.List<java.lang.String>,java.lang.CharSequence)`. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isExcludedFromSurfaces(int)(int surface)` Return true if the shortcut is excluded from specified surface. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isImmutable()()` Return if a shortcut is immutable, in which case it cannot be modified with any of `https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat` APIs. |
| `boolean` | `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isPinned()()` Return whether a shortcut is pinned. |
| `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 25) https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#toShortcutInfo()()` |

## Constants

### SURFACE_LAUNCHER

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/core#1.8.0)

```
public static final int SURFACE_LAUNCHER = 1
```

Indicates system surfaces managed by a launcher app. e.g. Long-Press Menu.

## Public methods

### getActivity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setActivity(android.content.ComponentName)` |   |

### getCategories

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Set<String> getCategories()
```

Return the categories set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setCategories(java.util.Set<java.lang.String>)`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setCategories(java.util.Set<java.lang.String>)` |   |

### getDisabledMessage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable CharSequence getDisabledMessage()
```

Return the message that should be shown when the user attempts to start a shortcut that is disabled.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setDisabledMessage(java.lang.CharSequence)` |   |

### getDisabledReason

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public int getDisabledReason()
```

Returns why a shortcut has been disabled.

### getExcludedFromSurfaces

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/core#1.8.0)

```
public int getExcludedFromSurfaces()
```

Returns a bitmask of all surfaces this shortcut is excluded from.

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/pm/ShortcutInfo.Builder.html#setExcludedFromSurfaces(int)` |   |

### getExtras

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable PersistableBundle getExtras()
```

### getId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 `https://developer.android.com/reference/android/content/pm/ShortcutManager.html` for details.

### getIntent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setIntent(android.content.Intent)` |   |

### getIntents

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @NonNull Intent[] getIntents()
```

Return the intent set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setIntents(android.content.Intent[])`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setIntents(android.content.Intent[])` |   |

### getLastChangedTimestamp

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public long getLastChangedTimestamp()
```

Last time when any of the fields was updated.

### getLocusId

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable LocusIdCompat getLocusId()
```

Gets the `https://developer.android.com/reference/androidx/core/content/LocusIdCompat` associated with this shortcut.

Used by the device's intelligence services to correlate objects (such as `https://developer.android.com/reference/androidx/core/app/NotificationCompat` and `https://developer.android.com/reference/android/view/contentcapture/ContentCaptureContext.html`) that are correlated.

### getLongLabel

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable CharSequence getLongLabel()
```

Return the long description of a shortcut.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setLongLabel(java.lang.CharSequence)` |   |

### getPackage

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull String getPackage()
```

Return the package name of the publisher app.

### getRank

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public int getRank()
```

Returns the rank of the shortcut set with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setRank(int)`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setRank(int)` |   |

### getShortLabel

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @NonNull CharSequence getShortLabel()
```

Return the short description of a shortcut.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setShortLabel(java.lang.CharSequence)` |   |

### getUserHandle

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable UserHandle getUserHandle()
```

`https://developer.android.com/reference/android/os/UserHandle.html` on which the publisher created this shortcut.

### hasKeyFieldsOnly

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean hasKeyFieldsOnly()
```

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

- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getId()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getPackage()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getActivity()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getLastChangedTimestamp()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isDynamic()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isPinned()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isDeclaredInManifest()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isImmutable()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isEnabled()`
- `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#getUserHandle()`

### isCached

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean isCached()
```

Return whether a shortcut is cached.

### isDeclaredInManifest

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
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 `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#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, `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isEnabled()` will be `false` and `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isImmutable()` will be `true`.

### isDynamic

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean isDynamic()
```

Return whether a shortcut is dynamic.

### isEnabled

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean isEnabled()
```

Returns `false` if a shortcut is disabled with `https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat#disableShortcuts(android.content.Context,java.util.List<java.lang.String>,java.lang.CharSequence)`.

### isExcludedFromSurfaces

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/core#1.8.0)

```
public boolean isExcludedFromSurfaces(int surface)
```

Return true if the shortcut is excluded from specified surface.

### isImmutable

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean isImmutable()
```

Return if a shortcut is immutable, in which case it cannot be modified with any of `https://developer.android.com/reference/androidx/core/content/pm/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, `https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat#isDeclaredInManifest()` returns `false`, but the shortcut is still immutable.

All shortcuts originally published via the `https://developer.android.com/reference/android/content/pm/ShortcutManager.html` APIs are all mutable.

### isPinned

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public boolean isPinned()
```

Return whether a shortcut is pinned.

### toShortcutInfo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@RequiresApi(value = 25)
public ShortcutInfo toShortcutInfo()
```

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html` | `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html` object from this compat object. |