ShortcutsScope

Receiver of shortcuts; every call maps directly onto ShortcutManagerCompat.

Properties

Link copied to clipboard

Whether the default launcher supports pinned shortcut requests.

Link copied to clipboard

Whether shortcut mutations are currently rate limited by the system.

Link copied to clipboard

Maximum number of dynamic + manifest shortcuts per launcher activity.

Functions

Link copied to clipboard
fun disable(vararg ids: String, message: CharSequence? = null)

Disables the shortcuts with the given ids. A pinned shortcut stays visible but greyed out; launching it shows message when provided.

Link copied to clipboard
fun dynamic(id: String, block: ShortcutSpec.() -> Unit)

Publishes (or updates, when id already exists) a dynamic shortcut via ShortcutManagerCompat.pushDynamicShortcut. If the dynamic shortcut limit is reached, the lowest-ranked shortcut is evicted automatically.

Link copied to clipboard
fun enable(vararg ids: String)

Re-enables previously disabled shortcuts. Ids that are not currently published are ignored.

Link copied to clipboard
fun pinned(id: String, block: PinnedShortcutSpec.() -> Unit): Boolean

Asks the launcher to pin a shortcut via ShortcutManagerCompat.requestPinShortcut. On API 26+ the system shows a confirmation dialog; below API 26 the legacy launcher broadcast is used.

Link copied to clipboard
fun remove(vararg ids: String)

Removes the dynamic shortcuts with the given ids.

Link copied to clipboard
fun removeAll()

Removes all dynamic shortcuts published by the app.

Link copied to clipboard

Reports that the shortcut with id was used, feeding the launcher's prediction ranking. Call this when the user performs the action from inside the app as well.

Link copied to clipboard
fun update(id: String, block: ShortcutSpec.() -> Unit)

Updates already-published shortcuts (dynamic or pinned) with the same id via ShortcutManagerCompat.updateShortcuts. Unlike dynamic, this never publishes a new shortcut.