# ShortcutManagerCompat

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/ShortcutManagerCompat.java+class:androidx.core.content.pm.ShortcutManagerCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

<br />

```
class ShortcutManagerCompat
```

<br />

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#EXTRA_SHORTCUT_ID() = "android.intent.extra.shortcut.ID"` Key to get the shortcut ID from extras of a share intent. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_CACHED() = 8` Include cached shortcuts in the result. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_DYNAMIC() = 2` Include dynamic shortcuts in the result. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_MANIFEST() = 1` Include manifest shortcuts in the result. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_PINNED() = 4` Include pinned shortcuts in the result. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#addDynamicShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutInfoList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!> )` Publish the list of dynamic shortcuts. |
| `java-static https://developer.android.com/reference/android/content/Intent.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#createShortcutResultIntent(android.content.Context,androidx.core.content.pm.ShortcutInfoCompat)( context: https://developer.android.com/reference/android/content/Context.html, shortcut: https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat )` Returns an Intent which can be used by the launcher to pin shortcut. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#disableShortcuts(android.content.Context,java.util.List<java.lang.String>,java.lang.CharSequence)( context: https://developer.android.com/reference/android/content/Context.html, shortcutIds: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>, disabledMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html? )` Disable pinned shortcuts, showing the user a custom error message when they try to select the disabled shortcuts. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#enableShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutInfoList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!> )` Re-enable pinned shortcuts that were previously disabled. |
| `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!>` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getDynamicShortcuts(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Return all dynamic shortcuts from the caller app. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getIconMaxHeight(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Return the max height for icons, in pixels. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getIconMaxWidth(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Return the max width for icons, in pixels. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getMaxShortcutCountPerActivity(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` |
| `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!>` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getShortcuts(android.content.Context,int)(context: https://developer.android.com/reference/android/content/Context.html, matchFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat`s that match `matchFlags`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#isRateLimitingActive(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Return `true` when rate-limiting is active for the caller app. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#isRequestPinShortcutSupported(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#pushDynamicShortcut(android.content.Context,androidx.core.content.pm.ShortcutInfoCompat)(context: https://developer.android.com/reference/android/content/Context.html, shortcut: https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat)` Publish a single dynamic shortcut. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeAllDynamicShortcuts(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Delete all dynamic shortcuts from the caller app. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeDynamicShortcuts(android.content.Context,java.util.List<java.lang.String>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutIds: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Delete dynamic shortcuts by ID. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeLongLivedShortcuts(android.content.Context,java.util.List<java.lang.String>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutIds: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Delete long lived shortcuts by ID. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#reportShortcutUsed(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html, shortcutId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Apps that publish shortcuts should call this method whenever the user selects the shortcut containing the given ID or when the user completes an action in the app that is equivalent to selecting the shortcut. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#requestPinShortcut(android.content.Context,androidx.core.content.pm.ShortcutInfoCompat,android.content.IntentSender)( context: https://developer.android.com/reference/android/content/Context.html, shortcut: https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat, callback: https://developer.android.com/reference/android/content/IntentSender.html? )` Request to create a pinned shortcut. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#setDynamicShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutInfoList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!> )` Publish the list of shortcuts. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#updateShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)( context: https://developer.android.com/reference/android/content/Context.html, shortcutInfoList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!> )` Update all existing shortcuts with the same IDs. |

## Constants

### EXTRA_SHORTCUT_ID

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

```
const val EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID": String!
```

Key to get the shortcut ID from extras of a share intent. When user selects a direct share item from ShareSheet, the app will receive a share intent which includes the ID of the corresponding shortcut in the extras field.

### FLAG_MATCH_CACHED

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

```
const val FLAG_MATCH_CACHED = 8: Int
```

Include cached shortcuts in the result.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getShortcuts(android.content.Context,int)` |   |

### FLAG_MATCH_DYNAMIC

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

```
const val FLAG_MATCH_DYNAMIC = 2: Int
```

Include dynamic shortcuts in the result.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getShortcuts(android.content.Context,int)` |   |

### FLAG_MATCH_MANIFEST

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

```
const val FLAG_MATCH_MANIFEST = 1: Int
```

Include manifest shortcuts in the result.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getShortcuts(android.content.Context,int)` |   |

### FLAG_MATCH_PINNED

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

```
const val FLAG_MATCH_PINNED = 4: Int
```

Include pinned shortcuts in the result.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getShortcuts(android.content.Context,int)` |   |

## Public functions

### addDynamicShortcuts

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

```
java-static fun addDynamicShortcuts(
    context: Context,
    shortcutInfoList: (Mutable)List<ShortcutInfoCompat!>
): Boolean
```

Publish the list of dynamic shortcuts. If there are already dynamic or pinned shortcuts with the same IDs, each mutable shortcut is updated.

On API \<= 31 Any shortcuts that are marked as excluded from launcher will not be passed to the `https://developer.android.com/reference/android/content/pm/ShortcutManager.html`, but they might still be available to assistant and other surfaces through alternative means.

This API will be rate-limited.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the call has succeeded. `false` if the call fails or is rate-limited. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getMaxShortcutCountPerActivity(android.content.Context)` is exceeded, or when trying to update immutable shortcuts. |

### createShortcutResultIntent

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

```
java-static fun createShortcutResultIntent(
    context: Context,
    shortcut: ShortcutInfoCompat
): Intent
```

Returns an Intent which can be used by the launcher to pin shortcut.

This should be used by an Activity to set result in response to `https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT`.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | context to use for the intent. |
| `shortcut: https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat` | new shortcut to pin |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html` | the intent that should be set as the result for the calling activity |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT` |   |

### disableShortcuts

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

```
java-static fun disableShortcuts(
    context: Context,
    shortcutIds: (Mutable)List<String!>,
    disabledMessage: CharSequence?
): Unit
```

Disable pinned shortcuts, showing the user a custom error message when they try to select the disabled shortcuts. For more details, read [Disable shortcuts](https://developer.android.com/guide/topics/ui/shortcuts/managing-shortcuts#disable-shortcuts). Compatibility behavior:

- API 25 and above, this method matches platform behavior.
- API 24 and earlier, this method behaves the same as `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeDynamicShortcuts(android.content.Context,java.util.List<java.lang.String>)`

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If trying to disable immutable shortcuts. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### enableShortcuts

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

```
java-static fun enableShortcuts(
    context: Context,
    shortcutInfoList: (Mutable)List<ShortcutInfoCompat!>
): Unit
```

Re-enable pinned shortcuts that were previously disabled. If the target shortcuts are already enabled, this method does nothing.

In API 31 and below any shortcuts that are marked as excluded from launcher will be ignored. Compatibility behavior:

- API 25 and above, this method matches platform behavior.
- API 24 and earlier, this method behaves the same as `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#addDynamicShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)`

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If trying to enable immutable shortcuts. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### getDynamicShortcuts

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

```
java-static fun getDynamicShortcuts(context: Context): (Mutable)List<ShortcutInfoCompat!>
```

Return all dynamic shortcuts from the caller app.

This API is intended to be used for examining what shortcuts are currently published. Re-publishing returned `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html`s via APIs such as `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#addDynamicShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)` may cause loss of information such as icons.

### getIconMaxHeight

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

```
java-static fun getIconMaxHeight(context: Context): Int
```

Return the max height for icons, in pixels.

### getIconMaxWidth

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

```
java-static fun getIconMaxWidth(context: Context): Int
```

Return the max width for icons, in pixels.

Note that this method returns max width of icon's visible part. Hence, it does not take into account the inset introduced by `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`. To calculate bitmap image to function as `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`, multiply 1 + 2 \* `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html#getExtraInsetFraction()` to the returned size.

### getMaxShortcutCountPerActivity

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

```
java-static fun getMaxShortcutCountPerActivity(context: Context): Int
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of static and dynamic shortcuts that each launcher icon can have at a time. |

### getShortcuts

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

```
java-static fun getShortcuts(context: Context, matchFlags: Int): (Mutable)List<ShortcutInfoCompat!>
```

Returns `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat`s that match `matchFlags`.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | context to use for the shortcuts. |
| `matchFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | result includes shortcuts matching this flags. Any combination of: - `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_MANIFEST()` - `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_DYNAMIC()` - `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_PINNED()` - `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#FLAG_MATCH_CACHED()` Compatibility behavior: <!-- --> - API 30 and above, this method matches platform behavior. - API 25 through 29, this method aggregates the result from corresponding platform api. - API 24 and earlier, this method can only returns dynamic shortcut. Calling this method with other flag will be ignored. |

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat!>` | list of `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat`s that match the flag. At least one of the `MATCH` flags should be set. Otherwise no shortcuts will be returned. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### isRateLimitingActive

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

```
java-static fun isRateLimitingActive(context: Context): Boolean
```

Return `true` when rate-limiting is active for the caller app.

For details, see [Rate limiting](https://developer.android.com/guide/topics/ui/shortcuts/managing-shortcuts#rate-limiting).

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### isRequestPinShortcutSupported

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

```
java-static fun isRequestPinShortcutSupported(context: Context): Boolean
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the launcher supports `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#requestPinShortcut(android.content.Context,androidx.core.content.pm.ShortcutInfoCompat,android.content.IntentSender)`, `false` otherwise |

### pushDynamicShortcut

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

```
java-static fun pushDynamicShortcut(context: Context, shortcut: ShortcutInfoCompat): Boolean
```

Publish a single dynamic shortcut. If there are already dynamic or pinned shortcuts with the same ID, each mutable shortcut is updated.

This method is useful when posting notifications which are tagged with shortcut IDs; In order to make sure shortcuts exist and are up-to-date, without the need to explicitly handle the shortcut count limit.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the call has succeeded. `false` if the call fails or is rate-limited. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if trying to update an immutable shortcut. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationManagerCompat#notify(int,android.app.Notification)` |   |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#setShortcutId(java.lang.String)` | If `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getMaxShortcutCountPerActivity(android.content.Context)` is already reached, an existing shortcut with the lowest rank will be removed to add space for the new shortcut. If the rank of the shortcut is not explicitly set, it will be set to zero, and shortcut will be added to the top of the list. Compatibility behavior: - API 30 and above, this method matches platform behavior. - API 25 to 29, this api is simulated by `https://developer.android.com/reference/android/content/pm/ShortcutManager.html#addDynamicShortcuts(java.util.List&lt;android.content.pm.ShortcutInfo&gt;)` and `https://developer.android.com/reference/android/content/pm/ShortcutManager.html#removeDynamicShortcuts(java.util.List&lt;java.lang.String&gt;)` and thus will be rate-limited. - API 24 and earlier, this method uses internal implementation and matches platform behavior. |

### removeAllDynamicShortcuts

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

```
java-static fun removeAllDynamicShortcuts(context: Context): Unit
```

Delete all dynamic shortcuts from the caller app. Note that if a shortcut is set as long-lived, it may still be available in the system as a cached shortcut even after being removed from the list of dynamic shortcuts.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeLongLivedShortcuts(android.content.Context,java.util.List<java.lang.String>)` |   |

### removeDynamicShortcuts

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

```
java-static fun removeDynamicShortcuts(
    context: Context,
    shortcutIds: (Mutable)List<String!>
): Unit
```

Delete dynamic shortcuts by ID. Note that if a shortcut is set as long-lived, it may still be available in the system as a cached shortcut even after being removed from the list of dynamic shortcuts.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeLongLivedShortcuts(android.content.Context,java.util.List<java.lang.String>)` |   |

### removeLongLivedShortcuts

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

```
java-static fun removeLongLivedShortcuts(
    context: Context,
    shortcutIds: (Mutable)List<String!>
): Unit
```

Delete long lived shortcuts by ID. Compatibility behavior:

- API 30 and above, this method matches platform behavior.
- API 29 and earlier, this method behaves the same as `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeDynamicShortcuts(android.content.Context,java.util.List<java.lang.String>)`

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### reportShortcutUsed

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

```
java-static fun reportShortcutUsed(context: Context, shortcutId: String): Unit
```

Apps that publish shortcuts should call this method whenever the user selects the shortcut containing the given ID or when the user completes an action in the app that is equivalent to selecting the shortcut. For more details, read about [tracking shortcut usage](https://developer.android.com/guide/topics/ui/shortcuts/managing-shortcuts#track-usage).

The information is accessible via `https://developer.android.com/reference/android/app/usage/UsageStatsManager.html#queryEvents(android.app.usage.UsageEventsQuery)` Typically, launcher apps use this information to build a prediction model so that they can promote the shortcuts that are likely to be used at the moment.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. This method is not supported on devices running SDK \<25 since the platform class will not be available. |

### requestPinShortcut

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

```
java-static fun requestPinShortcut(
    context: Context,
    shortcut: ShortcutInfoCompat,
    callback: IntentSender?
): Boolean
```

Request to create a pinned shortcut.

On API \<= 25 it creates a legacy shortcut with the provided icon, label and intent. For newer APIs it will create a `https://developer.android.com/reference/android/content/pm/ShortcutInfo.html` object which can be updated by the app.

Use `https://developer.android.com/reference/android/app/PendingIntent.html#getIntentSender()` to create a `https://developer.android.com/reference/android/content/IntentSender.html`.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | context to use for the request. |
| `shortcut: https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutInfoCompat` | new shortcut to pin |
| `callback: https://developer.android.com/reference/android/content/IntentSender.html?` | if not null, this intent will be sent when the shortcut is pinned |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the launcher supports this feature |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#isRequestPinShortcutSupported(android.content.Context)` |   |
| `https://developer.android.com/reference/android/content/IntentSender.html` |   |
| `https://developer.android.com/reference/android/app/PendingIntent.html#getIntentSender()` |   |

### setDynamicShortcuts

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

```
java-static fun setDynamicShortcuts(
    context: Context,
    shortcutInfoList: (Mutable)List<ShortcutInfoCompat!>
): Boolean
```

Publish the list of shortcuts. All existing dynamic shortcuts from the caller app will be replaced. If there are already pinned shortcuts with the same IDs, the mutable pinned shortcuts are updated.

On API \<= 31 Any shortcuts that are marked as excluded from launcher will not be passed to the `https://developer.android.com/reference/android/content/pm/ShortcutManager.html`, but they might still be available to assistant and other surfaces through alternative means.

This API will be rate-limited. Compatibility behavior:

- API 25 and above, this method matches platform behavior.
- API 24 and earlier, this method is equivalent of calling `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#removeAllDynamicShortcuts(android.content.Context)` and `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#addDynamicShortcuts(android.content.Context,java.util.List<androidx.core.content.pm.ShortcutInfoCompat>)` consecutively.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the call has succeeded. `false` if the call is rate-limited. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `https://developer.android.com/reference/kotlin/androidx/core/content/pm/ShortcutManagerCompat#getMaxShortcutCountPerActivity(android.content.Context)` is exceeded, or when trying to update immutable shortcuts. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when the user is locked. |

### updateShortcuts

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

```
java-static fun updateShortcuts(
    context: Context,
    shortcutInfoList: (Mutable)List<ShortcutInfoCompat!>
): Boolean
```

Update all existing shortcuts with the same IDs. Target shortcuts may be pinned and/or dynamic, but they must not be immutable.

On API \<= 31 Any shortcuts that are marked as excluded from launcher will not be passed to the `https://developer.android.com/reference/android/content/pm/ShortcutManager.html`, but they might still be available to assistant and other surfaces through alternative means.

This API will be rate-limited.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the call has succeeded. `false` if the call fails or is rate-limited. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If trying to update immutable shortcuts. |