# 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)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/car/app/suggestion/model/Suggestion.Builder "View this page in Java")


```
class Suggestion.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion` defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#setAction(android.app.PendingIntent)(action: https://developer.android.com/reference/android/app/PendingIntent.html)` Sets the `https://developer.android.com/reference/android/app/PendingIntent.html` for the suggestion action. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#setIcon(androidx.car.app.model.CarIcon)(icon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Sets a suggestion image to display. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#setIdentifier(java.lang.String)(identifier: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the suggestion identifier. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#setSubtitle(java.lang.CharSequence)(subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the suggestion subtitle formatted for the user's current locale. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/suggestion/model/Suggestion.Builder#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` 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)

```
Builder()
```

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

## Public functions

### build

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

```
fun build(): Suggestion
```

Constructs the `https://developer.android.com/reference/kotlin/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)

```
fun setAction(action: PendingIntent): Suggestion.Builder
```

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)

```
fun setIcon(icon: CarIcon): Suggestion.Builder
```

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/kotlin/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)

```
fun setIdentifier(identifier: String): Suggestion.Builder
```

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)

```
fun setSubtitle(subtitle: CharSequence): Suggestion.Builder
```

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/kotlin/androidx/car/app/model/CarText` |   |

### setTitle

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

```
fun setTitle(title: CharSequence): Suggestion.Builder
```

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/kotlin/androidx/car/app/model/CarText` |   |