# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# ShortcutInfo.Builder

`public static class ShortcutInfo.Builder`
`extends Object` ``

java.lang.Object
↳ | android.content.pm.ShortcutInfo.Builder

Builder class for `ShortcutInfo` objects.

See also:

- `ShortcutManager`

## Summary

### Public constructors
`Builder(Context context, String id)` Constructor.

### Public methods
`ShortcutInfo` | `build()` Creates a `ShortcutInfo` instance.
`ShortcutInfo.Builder` | `setActivity(ComponentName activity)` Sets the target activity.
`ShortcutInfo.Builder` | `setCategories(Set<String> categories)` Sets categories for a shortcut.
`ShortcutInfo.Builder` | `setDisabledMessage(CharSequence disabledMessage)` Sets the message that should be shown when the user attempts to start a shortcut that is disabled.
`ShortcutInfo.Builder` | `setExtras(PersistableBundle extras)` Extras that the app can set for any purpose.
`ShortcutInfo.Builder` | `setIcon(Icon icon)` Sets an icon of a shortcut.
`ShortcutInfo.Builder` | `setIntent(Intent intent)` Sets the intent of a shortcut.
`ShortcutInfo.Builder` | `setIntents(Intent[] intents)` Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack.
`ShortcutInfo.Builder` | `setLocusId(LocusId locusId)` Sets the `LocusId` associated with this shortcut.
`ShortcutInfo.Builder` | `setLongLabel(CharSequence longLabel)` Sets the text of a shortcut.
`ShortcutInfo.Builder` | `setLongLived(boolean londLived)` Sets if a shortcut would be valid even if it has been unpublished/invisible by the app (as a dynamic or pinned shortcut).
`ShortcutInfo.Builder` | `setPerson(Person person)` Add a person that is relevant to this shortcut.
`ShortcutInfo.Builder` | `setPersons(Person[] persons)` Sets multiple persons instead of a single person.
`ShortcutInfo.Builder` | `setRank(int rank)` "Rank" of a shortcut, which is a non-negative value that's used by the launcher app to sort shortcuts.
`ShortcutInfo.Builder` | `setShortLabel(CharSequence shortLabel)` Sets the short title of a shortcut.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder (Context context,
                    String id)

Constructor.

Parameters
`context` | `Context`: Client context.
`id` | `String`: ID of the shortcut.

## Public methods

### build

    public ShortcutInfo build ()

Creates a `ShortcutInfo` instance.

Returns
`ShortcutInfo` | This value cannot be `null`.

### setActivity

    public ShortcutInfo.Builder setActivity (ComponentName activity)

Sets the target activity. A shortcut will be shown along with this activity's icon on the launcher. When selecting a target activity, keep the following in mind:

- All dynamic shortcuts must have a target activity. When a shortcut with no target activity is published using `ShortcutManager#addDynamicShortcuts(List)` or `ShortcutManager#setDynamicShortcuts(List)`, the first main activity defined in the app's `AndroidManifest.xml` file is used.
- Only "main" activities—ones that define the `Intent#ACTION_MAIN` and `Intent#CATEGORY_LAUNCHER` intent filters—can be target activities.
- By default, the first main activity defined in the app's manifest is the target activity.
- A target activity must belong to the publisher app.

Parameters
`activity` | `ComponentName`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.getActivity()`

### setCategories

    public ShortcutInfo.Builder setCategories (Set<String> categories)

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

Parameters
`categories` | `Set`

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION`
- `ShortcutInfo.getCategories()`

### setDisabledMessage

    public ShortcutInfo.Builder setDisabledMessage (CharSequence disabledMessage)

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

Parameters
`disabledMessage` | `CharSequence`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.getDisabledMessage()`

### setExtras

    public ShortcutInfo.Builder setExtras (PersistableBundle extras)

Extras that the app can set for any purpose.

Apps can store arbitrary shortcut metadata in extras and retrieve the metadata later using `ShortcutInfo#getExtras()`.

Parameters
`extras` | `PersistableBundle`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

### setIcon

    public ShortcutInfo.Builder setIcon (Icon icon)

Sets an icon of a shortcut.

Icons are not available on `ShortcutInfo` instances returned by `ShortcutManager` or `LauncherApps`. The default launcher app can use `LauncherApps#getShortcutIconDrawable(ShortcutInfo, int)` or `LauncherApps#getShortcutBadgedIconDrawable(ShortcutInfo, int)` to fetch shortcut icons.

Tints set with `Icon#setTint` or `Icon#setTintList` are not supported and will be ignored.

Only icons created with `Icon#createWithBitmap(Bitmap)`, `Icon#createWithAdaptiveBitmap(Bitmap)` and `Icon#createWithResource` are supported. Other types, such as URI-based icons, are not supported.

Parameters
`icon` | `Icon`

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `LauncherApps.getShortcutIconDrawable(ShortcutInfo, int)`
- `LauncherApps.getShortcutBadgedIconDrawable(ShortcutInfo, int)`

### setIntent

    public ShortcutInfo.Builder setIntent (Intent intent)

Sets the intent of a shortcut. Alternatively, `setIntents(android.content.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 with `ShortcutManager#addDynamicShortcuts(List)` or `ShortcutManager#setDynamicShortcuts(List)`.

A shortcut can launch any intent that the publisher app has permission to launch. For example, a shortcut can launch an unexported activity within the publisher app. A shortcut intent doesn't have to point at the target activity.

The given `intent` can contain extras, but these extras must contain values of primitive types in order for the system to persist these values.

Parameters
`intent` | `Intent`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.getIntent()`
- `setIntents(Intent[])`

### setIntents

    public ShortcutInfo.Builder setIntents (Intent[] intents)

Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack. Use `TaskStackBuilder` to build intents. The last element in the list represents the only intent that doesn't place an activity on the back stack. See the `ShortcutManager` javadoc for details.

Parameters
`intents` | `Intent`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `setIntent(Intent)`
- `ShortcutInfo.getIntents()`
- `Context.startActivities(Intent[])`
- `TaskStackBuilder`

### setLocusId

    public ShortcutInfo.Builder setLocusId (LocusId locusId)

Sets the `LocusId` associated with this shortcut.

This method should be called when the `LocusId` is used in other places (such as `Notification` and `ContentCaptureContext`) so the device's intelligence services can correlate them.

Parameters
`locusId` | `LocusId`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

### setLongLabel

    public ShortcutInfo.Builder setLongLabel (CharSequence longLabel)

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.

Parameters
`longLabel` | `CharSequence`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.getLongLabel()`

### setLongLived

    public ShortcutInfo.Builder setLongLived (boolean londLived)

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.

Parameters
`londLived` | `boolean`

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

### setPerson

    public ShortcutInfo.Builder setPerson (Person person)

Add a person that is relevant to this shortcut. Alternatively, `setPersons(android.app.Person[])` can be used to add multiple persons to a shortcut.

This is an optional field, but the addition of person may cause this shortcut to appear more prominently in the user interface (e.g. ShareSheet).

A person should usually contain a uri in order to benefit from the ranking boost. However, even if no uri is provided, it's beneficial to provide people in the shortcut, such that listeners and voice only devices can announce and handle them properly.

Parameters
`person` | `Person`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `Person`
- `setPersons(Person[])`

### setPersons

    public ShortcutInfo.Builder setPersons (Person[] persons)

Sets multiple persons instead of a single person.

Parameters
`persons` | `Person`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `Person`
- `setPerson(Person)`

### setRank

    public ShortcutInfo.Builder setRank (int rank)

"Rank" of a shortcut, which is a non-negative value that's used by the launcher app to sort shortcuts. See `ShortcutInfo#getRank()` for details.

Parameters
`rank` | `int`

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

### setShortLabel

    public ShortcutInfo.Builder setShortLabel (CharSequence shortLabel)

Sets the short title of a shortcut.

This is a mandatory field when publishing a new shortcut with `ShortcutManager#addDynamicShortcuts(List)` or `ShortcutManager#setDynamicShortcuts(List)`.

This field is intended to be a concise description of a shortcut.

The recommended maximum length is 10 characters.

Parameters
`shortLabel` | `CharSequence`: This value cannot be `null`.

Returns
`ShortcutInfo.Builder` | This value cannot be `null`.

See also:

- `ShortcutInfo.getShortLabel()`

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*