# ShortcutInfoCompat.Builder

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Ctors](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#)  

# ShortcutInfoCompat.Builder

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static


class
ShortcutInfoCompat.Builder
`  
`

extends Object


``


`

|---|----------------------------------------------------------|
| java.lang.Object                                            ||
| ↳ | android.support.v4.content.pm.ShortcutInfoCompat.Builder |

<br />

*** ** * ** ***

Builder class for[ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat)objects.

## Summary

|                                                                                                                                               ### Public constructors                                                                                                                                               ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#ShortcutInfoCompat.Builder(android.content.Context, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String id) ` |

|                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat)                 | ` `[build](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#build())`() ` Creates a[ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat)instance.                                                                                                                 |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setActivity](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setActivity(android.content.ComponentName))`(`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)` activity) ` Sets the target activity.                                                                         |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setAlwaysBadged](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setAlwaysBadged())`() ` Badges the icon before passing it over to the Launcher.                                                                                                                                                                      |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setDisabledMessage](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setDisabledMessage(java.lang.CharSequence))`(CharSequence disabledMessage) ` Sets the message that should be shown when the user attempts to start a shortcut that is disabled.                                                                   |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setIcon](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setIcon(android.support.v4.graphics.drawable.IconCompat))`(`[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat)` icon) ` Sets an icon of a shortcut.                                                       |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setIntent](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setIntent(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Sets the intent of a shortcut.                                                                                               |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setIntents](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setIntents(android.content.Intent[]))`(`[Intent[]](https://developer.android.com/reference/android/content/Intent.html)` intents) ` Sets multiple intents instead of a single intent, in order to launch an activity with other activities in back stack. |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setLongLabel](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setLongLabel(java.lang.CharSequence))`(CharSequence longLabel) ` Sets the text of a shortcut.                                                                                                                                                           |
| ` `[ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | ` `[setShortLabel](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setShortLabel(java.lang.CharSequence))`(CharSequence shortLabel) ` Sets the short title of a shortcut.                                                                                                                                                 |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### ShortcutInfoCompat.Builder

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder (Context context, 
                String id)
```

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |
| `id`      | `String` <br />  |

## Public methods

### build

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat build ()
```

Creates a[ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat)instance.

<br />

|                                                        Returns                                                         ||
|----------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat) | <br /> |

### setActivity

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setActivity (ComponentName activity)
```

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

<br />

|             Parameters             ||
|------------|------------------------|
| `activity` | `ComponentName` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

**See also:**

- [getActivity()](https://developer.android.com/https://developer.android.com/reference/android/content/pm/ShortcutInfo#getActivity())
- [setActivity(ComponentName)](https://developer.android.com/https://developer.android.com/reference/android/content/pm/ShortcutInfo.Builder#setActivity(android.content.ComponentName))  

### setAlwaysBadged

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setAlwaysBadged ()
```

Badges the icon before passing it over to the Launcher.

Launcher automatically badges[ShortcutInfo](https://developer.android.com/reference/android/content/pm/ShortcutInfo.html), so only the legacy shortcut icon,[Intent.ShortcutIconResource](https://developer.android.com/reference/android/content/Intent.ShortcutIconResource.html)is badged. This field is ignored when using[ShortcutInfo](https://developer.android.com/reference/android/content/pm/ShortcutInfo.html)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.

<br />

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

**See also:**

- [setActivity(ComponentName)](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#setActivity(android.content.ComponentName))  

### setDisabledMessage

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setDisabledMessage (CharSequence disabledMessage)
```

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

<br />

|                Parameters                ||
|-------------------|-----------------------|
| `disabledMessage` | `CharSequence` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

**See also:**

- [getDisabledMessage()](https://developer.android.com/https://developer.android.com/reference/android/content/pm/ShortcutInfo#getDisabledMessage())  

### setIcon

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setIcon (IconCompat icon)
```

Sets an icon of a shortcut.

<br />

|         Parameters          ||
|--------|---------------------|
| `icon` | `IconCompat` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

### setIntent

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setIntent (Intent intent)
```

Sets the intent of a shortcut. Alternatively,[setIntents(Intent[])](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder#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.

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

<br />

|        Parameters         ||
|----------|-----------------|
| `intent` | `Intent` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

### setIntents

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.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](https://developer.android.com/reference/android/app/TaskStackBuilder.html)to build intents. The last element in the list represents the only intent that doesn't place an activity on the back stack.

<br />

|         Parameters         ||
|-----------|-----------------|
| `intents` | `Intent` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

### setLongLabel

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.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.

<br />

|             Parameters             ||
|-------------|-----------------------|
| `longLabel` | `CharSequence` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

### setShortLabel

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ShortcutInfoCompat.Builder setShortLabel (CharSequence shortLabel)
```

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.

<br />

|             Parameters              ||
|--------------|-----------------------|
| `shortLabel` | `CharSequence` <br /> |

|                                                                Returns                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------|
| [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder) | <br /> |

-

  ## Classes

  - [ActivityInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ActivityInfoCompat)
  - [ShortcutInfoCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat)
  - [ShortcutInfoCompat.Builder](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutInfoCompat.Builder)
  - [ShortcutManagerCompat](https://developer.android.com/reference/android/support/v4/content/pm/ShortcutManagerCompat)