# LongMessageTemplate.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/model/LongMessageTemplate.java+class:androidx.car.app.model.LongMessageTemplate.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

*** ** * ** ***

<br />

```
@RequiresCarApi(value = 2)
class LongMessageTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#Builder(java.lang.CharSequence)(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#addAction(androidx.car.app.model.Action)(action: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to display along with the message. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate` defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template or `null` to not display an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)(headerAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that will be displayed in the header of the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the title of the template. |

## Public constructors

### Builder

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

```
Builder(message: CharSequence)
```

Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/LongMessageTemplate.Builder` instance.

| Parameters |
|---|---|
| `message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | the text message to display in the template. This message will only be displayed when the car is parked. |

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

## Public functions

### addAction

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

```
fun addAction(action: Action): LongMessageTemplate.Builder
```

Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to display along with the message.

#### Requirements

This template allows up to 2 `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s in its body, and they must use a `https://developer.android.com/reference/kotlin/androidx/car/app/model/ParkedOnlyOnClickListener`. One of these actions can be declared as primary via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setFlags(int)`. Each action's title color can be customized with `https://developer.android.com/reference/kotlin/androidx/car/app/model/ForegroundCarColorSpan` instances. Any other span is not supported.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `action` does not meet the requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `action` is `null` |

### build

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

```
fun build(): LongMessageTemplate
```

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

#### Requirements

A non-empty message must be set on the template.

If none of the header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`, the header title or the action strip have been set on the template, the header is hidden.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the message is empty |

### setActionStrip

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

```
fun setActionStrip(actionStrip: ActionStrip): LongMessageTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template or `null` to not display an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`.

Unless set with this method, the template will not have an action strip.

#### Requirements

This template allows up to 2 `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s in its `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`. Of the 2 allowed `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s, one of them can contain a title as set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`. Otherwise, only `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s with icons are allowed.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `actionStrip` does not meet the requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `actionStrip` is `null` |

### setHeaderAction

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

```
fun setHeaderAction(headerAction: Action): LongMessageTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that will be displayed in the header of the template.

Unless set with this method, the template will not have a header action.

#### Requirements

This template only supports either one of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#APP_ICON()` and `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#BACK()` as a header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `headerAction` does not meet the template's requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `headerAction` is `null` |

### setTitle

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

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

Sets the title of the template.

Unless set with this method, the template will not have a title.

Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan`s are supported in the input string.

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

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