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

*** ** * ** ***

<br />

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

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder#Builder(androidx.car.app.model.signin.SignInTemplate.SignInMethod)(signInMethod: https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.SignInMethod)` Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.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 alongside the sign-in content. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder#build()()` Constructs the template defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.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. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder#setAdditionalText(java.lang.CharSequence)(additionalText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets additional text, such as disclaimers, links to terms of services, to show in the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.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/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder#setInstructions(java.lang.CharSequence)(instructions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the text to show as instructions of the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder#setLoading(boolean)(isLoading: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the template is in a loading state. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.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.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
Builder(signInMethod: SignInTemplate.SignInMethod)
```

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

| Parameters |
|---|---|
| `signInMethod: https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.SignInMethod` | the sign-in method to use in this template |

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

## Public functions

### addAction

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

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

Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to display alongside the sign-in content.

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

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/NullPointerException.html` | if `action` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `action` does not meet the requirements |

### build

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

```
fun build(): SignInTemplate
```

Constructs the template defined by this builder.

#### Requirements

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 template does not have either a title or header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` set |

### setActionStrip

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

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

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template.

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

### setAdditionalText

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

```
fun setAdditionalText(additionalText: CharSequence): SignInTemplate.Builder
```

Sets additional text, such as disclaimers, links to terms of services, to show in the template.

Unless set with this method, the template will not have additional text.

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

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

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

### setHeaderAction

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

```
fun setHeaderAction(headerAction: Action): SignInTemplate.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` |

### setInstructions

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

```
fun setInstructions(instructions: CharSequence): SignInTemplate.Builder
```

Sets the text to show as instructions of the template.

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

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

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` | for details on text handling and span support. |

### setLoading

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

```
fun setLoading(isLoading: Boolean): SignInTemplate.Builder
```

Sets whether the template is in a loading state.

If set to `true`, the UI will display a loading indicator instead of the `https://developer.android.com/reference/kotlin/androidx/car/app/model/signin/SignInTemplate.SignInMethod`. The caller is expected to call `https://developer.android.com/reference/kotlin/androidx/car/app/Screen#invalidate()` once loading is complete.

### setTitle

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

```
fun setTitle(title: CharSequence): SignInTemplate.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 |