Builder

open class Builder
kotlin.Any
   ↳ androidx.core.content.pm.ShortcutInfoCompat.Builder

Builder class for ShortcutInfoCompat objects.

Summary

Public constructors

<init>(@NonNull context: Context, @NonNull id: String)

Public methods

open ShortcutInfoCompat

Creates a ShortcutInfoCompat instance.

open ShortcutInfoCompat.Builder
setActivity(@NonNull activity: ComponentName)

Sets the target activity.

open ShortcutInfoCompat.Builder

Badges the icon before passing it over to the Launcher.

open ShortcutInfoCompat.Builder
setCategories(@NonNull categories: MutableSet<String!>)

Sets categories for a shortcut.

open ShortcutInfoCompat.Builder
setDisabledMessage(@NonNull disabledMessage: CharSequence)

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

open ShortcutInfoCompat.Builder

Sets an icon of a shortcut.

open ShortcutInfoCompat.Builder
setIntent(@NonNull intent: Intent)

Sets the intent of a shortcut.

open ShortcutInfoCompat.Builder
setIntents(@NonNull intents: Array<Intent!>)

Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack.

open ShortcutInfoCompat.Builder
setLongLabel(@NonNull longLabel: CharSequence)

Sets the text of a shortcut.

open ShortcutInfoCompat.Builder

open 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).

open ShortcutInfoCompat.Builder
setPerson(@NonNull person: Person)

Associate a person to a shortcut.

open ShortcutInfoCompat.Builder
setPersons(@NonNull persons: Array<Person!>)

Sets multiple persons instead of a single person.

open ShortcutInfoCompat.Builder
setRank(rank: Int)

Sets rank of a shortcut, which is a non-negative value that's used by the system to sort shortcuts.

open ShortcutInfoCompat.Builder
setShortLabel(@NonNull shortLabel: CharSequence)

Sets the short title of a shortcut.

Public constructors

<init>

Builder(@NonNull context: Context, @NonNull id: String)

Public methods

build

@NonNull open fun build(): ShortcutInfoCompat

Creates a ShortcutInfoCompat instance.

setActivity

@NonNull open fun setActivity(@NonNull activity: ComponentName): ShortcutInfoCompat.Builder

Sets the target activity. A shortcut will be shown along with this activity's icon on the launcher.

setAlwaysBadged

@NonNull open 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.

setCategories

@NonNull open fun setCategories(@NonNull categories: MutableSet<String!>): ShortcutInfoCompat.Builder

Sets categories for a shortcut. Launcher apps may use this information to categorize shortcuts.

setDisabledMessage

@NonNull open fun setDisabledMessage(@NonNull disabledMessage: CharSequence): ShortcutInfoCompat.Builder

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

setIcon

@NonNull open fun setIcon(icon: IconCompat!): ShortcutInfoCompat.Builder

Sets an icon of a shortcut.

setIntent

@NonNull open fun setIntent(@NonNull intent: Intent): ShortcutInfoCompat.Builder

Sets the intent of a shortcut. Alternatively, setIntents(Intent[]) 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

@NonNull open fun setIntents(@NonNull 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.

setLongLabel

@NonNull open fun setLongLabel(@NonNull 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

@NonNull open fun setLongLived(): ShortcutInfoCompat.Builder

Deprecated: Use {@ink #setLongLived(boolean)) instead.

setLongLived

@NonNull open 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

@NonNull open fun setPerson(@NonNull person: Person): ShortcutInfoCompat.Builder

Associate a person to a shortcut. Alternatively, setPersons(Person[]) can be used to add multiple persons to a shortcut.

This is an optional field when publishing a new shortcut.

See Also

setPersons

@NonNull open fun setPersons(@NonNull persons: Array<Person!>): ShortcutInfoCompat.Builder

Sets multiple persons instead of a single person.

setRank

@NonNull open 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.

setShortLabel

@NonNull open fun setShortLabel(@NonNull 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.