# Suggestion.Builder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/suggestion/model/Suggestion.java+class:androidx.car.app.suggestion.model.Suggestion.Builder) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

*** ** * ** ***


```
public final class Suggestion.Builder
```

<br />

*** ** * ** ***

A builder of `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#Builder()()` Returns an empty `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#setAction(android.app.PendingIntent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html action)` Sets the `https://developer.android.com/reference/android/app/PendingIntent.html` for the suggestion action. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#setIcon(androidx.car.app.model.CarIcon)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon icon)` Sets a suggestion image to display. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#setIdentifier(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html identifier)` Sets the suggestion identifier. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#setSubtitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html subtitle)` Sets the suggestion subtitle formatted for the user's current locale. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder#setTitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title)` Sets the suggestion title formatted for the user's current locale. |

## Public constructors

### Builder

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public Builder()
```

Returns an empty `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder` instance.

## Public methods

### build

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion build()
```

Constructs the `https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion` defined by this builder.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if any of the files are `null` or if the title and the subtitle are empty. |

### setAction

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion.Builder setAction(@NonNull PendingIntent action)
```

Sets the `https://developer.android.com/reference/android/app/PendingIntent.html` for the suggestion action.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `pendingIntent` is `null` |

### setIcon

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion.Builder setIcon(@NonNull CarIcon icon)
```

Sets a suggestion image to display.

#### Image Sizing Guidance

To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 128 x 128 dp bounding box. If the image exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving the aspect ratio. Icon images are expected to be tintable.

See `https://developer.android.com/reference/androidx/car/app/model/CarIcon` for more details related to providing icon and image resources that work with different car screen pixel densities.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |

### setIdentifier

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion.Builder setIdentifier(@NonNull String identifier)
```

Sets the suggestion identifier.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `identifier` is `null` |

### setSubtitle

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion.Builder setSubtitle(@NonNull CharSequence subtitle)
```

Sets the suggestion subtitle formatted for the user's current locale.

Spans are not supported in the input string and will be ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `subtitle` is `null` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/CarText` |   |

### setTitle

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Suggestion.Builder setTitle(@NonNull CharSequence title)
```

Sets the suggestion title formatted for the user's current locale.

Spans are not supported in the input string and will be ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is `null` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/CarText` |   |