Android 12 Developer Preview is here! Try it out, and give us your feedback!

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
setExtras(@NonNull extras: PersistableBundle)

Extras that the app can set for any purpose.

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

Sets the corresponding fields indicating this shortcut is aimed for conversation.

open ShortcutInfoCompat.Builder
setLocusId(@Nullable locusId: LocusIdCompat?)

Sets the LocusIdCompat associated with this shortcut.

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
  • 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.

setDisabledMessage

@NonNull open fun setDisabledMessage(@NonNull disabledMessage