ShortcutInfoCompat.Builder
class ShortcutInfoCompat.Builder
Builder class for ShortcutInfoCompat
objects.
Summary
Public functions |
|
---|---|
ShortcutInfoCompat.Builder |
addCapabilityBinding(capability: String) Associates a shortcut with a capability without any parameters. |
ShortcutInfoCompat.Builder |
addCapabilityBinding( Associates a shortcut with a capability, and a parameter of that capability. |
ShortcutInfoCompat |
build() Creates a |
ShortcutInfoCompat.Builder |
setActivity(activity: ComponentName) Sets the target activity. |
ShortcutInfoCompat.Builder |
Badges the icon before passing it over to the Launcher. |
ShortcutInfoCompat.Builder |
setCategories(categories: (Mutable)Set<String!>) Sets categories for a shortcut. |
ShortcutInfoCompat.Builder |
setDisabledMessage(disabledMessage: CharSequence) Sets the message that should be shown when the user attempts to start a shortcut that is disabled. |
ShortcutInfoCompat.Builder |
setExcludedFromSurfaces(surfaces: Int) Sets which surfaces a shortcut will be excluded from. |
ShortcutInfoCompat.Builder |
setExtras(extras: PersistableBundle) Extras that the app can set for any purpose. |
ShortcutInfoCompat.Builder |
setIcon(icon: IconCompat!) Sets an icon of a shortcut. |
ShortcutInfoCompat.Builder |
Sets the intent of a shortcut. |
ShortcutInfoCompat.Builder |
setIntents(intents: Array<Intent!>) Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack. |
ShortcutInfoCompat.Builder |
Sets the corresponding fields indicating this shortcut is aimed for conversation. |
ShortcutInfoCompat.Builder |
setLocusId(locusId: LocusIdCompat?) Sets the |
ShortcutInfoCompat.Builder |
setLongLabel(longLabel: CharSequence) Sets the text of a shortcut. |
ShortcutInfoCompat.Builder |
This function is deprecated. Use {@ink #setLongLived(boolean)) instead. |
ShortcutInfoCompat.Builder |
setLongLived(longLived: Boolean) Sets if a shortcut would be valid even if it has been unpublished/invisible by the app (as a dynamic or pinned shortcut). |
ShortcutInfoCompat.Builder |
Associate a person to a shortcut. |
ShortcutInfoCompat.Builder |
setPersons(persons: Array<Person!>) Sets multiple persons instead of a single person. |
ShortcutInfoCompat.Builder |
Sets rank of a shortcut, which is a non-negative value that's used by the system to sort shortcuts. |
ShortcutInfoCompat.Builder |
setShortLabel(shortLabel: CharSequence) Sets the short title of a shortcut. |
ShortcutInfoCompat.Builder |
setSliceUri(sliceUri: Uri) Sets the slice uri for a shortcut. |
Public functions
addCapabilityBinding
fun addCapabilityBinding(capability: String): ShortcutInfoCompat.Builder
Associates a shortcut with a capability without any parameters. Used when the shortcut is an instance of a capability.
This method can be called multiple times to associate multiple capabilities with this shortcut.
Parameters | |
---|---|
capability: String |
capability associated with the shortcut. e.g. actions.intent .START_EXERCISE. |
addCapabilityBinding
fun addCapabilityBinding(
capability: String,
parameter: String,
parameterValues: (Mutable)List<String!>
): ShortcutInfoCompat.Builder
Associates a shortcut with a capability, and a parameter of that capability. Used when the shortcut is an instance of a capability.
This method can be called multiple times to associate multiple capabilities with this shortcut, or add multiple parameters to the same capability.
Parameters | |
---|---|
capability: String |
capability associated with the shortcut. e.g. actions.intent .START_EXERCISE. |
parameter: String |
the parameter associated with the capability. e.g. exercise.name. |
parameterValues: (Mutable)List<String!> |
a list of values for that parameters. The first value will be the primary name, while the rest will be alternative names. If the values are empty, then the parameter will not be saved in the shortcut. |
setActivity
fun setActivity(activity: ComponentName): ShortcutInfoCompat.Builder
Sets the target activity. A shortcut will be shown along with this activity's icon on the launcher.
See also | |
---|---|
getActivity |
|
setActivity |
setAlwaysBadged
fun setAlwaysBadged(): ShortcutInfoCompat.Builder
Badges the icon before passing it over to the Launcher.
Launcher automatically badges ShortcutInfo
, so only the legacy shortcut icon, Intent.ShortcutIconResource
is badged. This field is ignored when using ShortcutInfo
on API 25 and above.
If the shortcut is associated with an activity, the activity icon is used as the badge, otherwise application icon is used.
See also | |
---|---|
setActivity |
setCategories
fun setCategories(categories: (Mutable)Set<String!>): ShortcutInfoCompat.Builder
Sets categories for a shortcut.
- Launcher apps may use this information to categorize shortcuts
- Used by the system to associate a published Sharing Shortcut with supported mimeTypes. Required for published Sharing Shortcuts with a matching category declared in share targets, defined in the app's manifest linked shortcuts xml file.
See also | |
---|---|
getCategories |
setDisabledMessage
fun setDisabledMessage(disabledMessage: CharSequence): ShortcutInfoCompat.Builder
Sets the message that should be shown when the user attempts to start a shortcut that is disabled.
See also | |
---|---|
getDisabledMessage |
setExcludedFromSurfaces
fun setExcludedFromSurfaces(surfaces: Int): ShortcutInfoCompat.Builder
Sets which surfaces a shortcut will be excluded from. This API is reserved for future extension. Currently, marking a shortcut to be excluded from SURFACE_LAUNCHER
will not publish the shortcut, thus the following operations will be a no-op: pushDynamicShortcut
, addDynamicShortcuts
, and setDynamicShortcuts
.
On API <= 31, shortcuts that are excluded from SURFACE_LAUNCHER
are not actually sent to ShortcutManager
. These shortcuts might still be made available to other surfaces via alternative means.
setExtras
fun setExtras(extras: PersistableBundle): ShortcutInfoCompat.Builder
Extras that the app can set for any purpose.
Apps can store arbitrary shortcut metadata in extras and retrieve the metadata later using getExtras
.
See also | |
---|---|
getExtras |
setIcon
fun setIcon(icon: IconCompat!): ShortcutInfoCompat.Builder
Sets an icon of a shortcut.
setIntent
fun setIntent(intent: Intent): ShortcutInfoCompat.Builder
Sets the intent of a shortcut. Alternatively, setIntents
can be used to launch an activity with other activities in the back stack.
This is a mandatory field when publishing a new shortcut.
The given intent
can contain extras, but these extras must contain values of primitive types in order for the system to persist these values.
setIntents
fun setIntents(intents: Array<Intent!>): ShortcutInfoCompat.Builder
Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack. Use android.app.TaskStackBuilder
to build intents. The last element in the list represents the only intent that doesn't place an activity on the back stack.
setIsConversation
fun setIsConversation(): ShortcutInfoCompat.Builder
Sets the corresponding fields indicating this shortcut is aimed for conversation.
If the shortcut is not associated with a LocusIdCompat
, a LocusIdCompat
based on getId
will be added upon build
Additionally, the shortcut will be long-lived.
See also | |
---|---|
setLongLived |
setLocusId
fun setLocusId(locusId: LocusIdCompat?): ShortcutInfoCompat.Builder
Sets the LocusIdCompat
associated with this shortcut.
This method should be called when the LocusIdCompat
is used in other places (such as androidx.core.app.NotificationCompat
and android.view.contentcapture.ContentCaptureContext
) so the device's intelligence services can correlate them.
setLongLabel
fun setLongLabel(longLabel: CharSequence): ShortcutInfoCompat.Builder
Sets the text of a shortcut.
This field is intended to be more descriptive than the shortcut title. The launcher shows this instead of the short title when it has enough space.
The recommend maximum length is 25 characters.
setLongLived
fun setLongLived(longLived: Boolean): ShortcutInfoCompat.Builder
Sets if a shortcut would be valid even if it has been unpublished/invisible by the app (as a dynamic or pinned shortcut). If it is long lived, it can be cached by various system services even after it has been unpublished as a dynamic shortcut.
setPerson
fun setPerson(person: Person): ShortcutInfoCompat.Builder
Associate a person to a shortcut. Alternatively, setPersons
can be used to add multiple persons to a shortcut.
This is an optional field when publishing a new shortcut.
See also | |
---|---|
Person |
setPersons
fun setPersons(persons: Array<Person!>): ShortcutInfoCompat.Builder
Sets multiple persons instead of a single person.
setRank
fun setRank(rank: Int): ShortcutInfoCompat.Builder
Sets rank of a shortcut, which is a non-negative value that's used by the system to sort shortcuts. Lower value means higher importance.
See also | |
---|---|
getRank |
for details. |
setShortLabel
fun setShortLabel(shortLabel: CharSequence): ShortcutInfoCompat.Builder
Sets the short title of a shortcut.
This is a mandatory field when publishing a new shortcut.
This field is intended to be a concise description of a shortcut.
The recommended maximum length is 10 characters.
setSliceUri
fun setSliceUri(sliceUri: Uri): ShortcutInfoCompat.Builder
Sets the slice uri for a shortcut. The uri will be used if this shortcuts represents a slice, instead of an intent.