# 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)
public final class SignInTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#Builder(androidx.car.app.model.signin.SignInTemplate.SignInMethod)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.SignInMethod signInMethod)` Returns a `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#addAction(androidx.car.app.model.Action)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Action action)` Adds an `https://developer.android.com/reference/androidx/car/app/model/Action` to display alongside the sign-in content. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#build()()` Constructs the template defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip actionStrip)` Sets the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#setAdditionalText(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html additionalText)` Sets additional text, such as disclaimers, links to terms of services, to show in the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Action headerAction)` Sets the `https://developer.android.com/reference/androidx/car/app/model/Action` that will be displayed in the header of the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#setInstructions(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html instructions)` Sets the text to show as instructions of the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder#setLoading(boolean)(boolean isLoading)` Sets whether the template is in a loading state. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.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 title of the template. |

## Public constructors

### Builder

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

```
public Builder(@NonNull SignInTemplate.SignInMethod signInMethod)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/signin/SignInTemplate.SignInMethod 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 methods

### addAction

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

```
public @NonNull SignInTemplate.Builder addAction(@NonNull Action action)
```

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

#### Requirements

This template allows up to 2 `https://developer.android.com/reference/androidx/car/app/model/Action`s in its body, and they must use a `https://developer.android.com/reference/androidx/car/app/model/ParkedOnlyOnClickListener`.

Each action's title color can be customized with `https://developer.android.com/reference/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)

```
public @NonNull SignInTemplate build()
```

Constructs the template defined by this builder.

#### Requirements

If none of the header `https://developer.android.com/reference/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/androidx/car/app/model/Action` set |

### setActionStrip

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

```
public @NonNull SignInTemplate.Builder setActionStrip(@NonNull ActionStrip actionStrip)
```

Sets the `https://developer.android.com/reference/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/androidx/car/app/model/Action`s in its `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Of the 2 allowed `https://developer.android.com/reference/androidx/car/app/model/Action`s, one of them can contain a title as set via `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`. Otherwise, only `https://developer.android.com/reference/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)

```
public @NonNull SignInTemplate.Builder setAdditionalText(@NonNull CharSequence additionalText)
```

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/androidx/car/app/model/ClickableSpan`, `https://developer.android.com/reference/androidx/car/app/model/DistanceSpan`, and `https://developer.android.com/reference/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/androidx/car/app/model/CarText` |   |

### setHeaderAction

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

```
public @NonNull SignInTemplate.Builder setHeaderAction(@NonNull Action headerAction)
```

Sets the `https://developer.android.com/reference/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/androidx/car/app/model/Action#APP_ICON()` and `https://developer.android.com/reference/androidx/car/app/model/Action#BACK()` as a header `https://developer.android.com/reference/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)

```
public @NonNull SignInTemplate.Builder setInstructions(@NonNull CharSequence instructions)
```

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/androidx/car/app/model/DistanceSpan`, `https://developer.android.com/reference/androidx/car/app/model/DurationSpan`, and `https://developer.android.com/reference/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/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)

```
public @NonNull SignInTemplate.Builder setLoading(boolean isLoading)
```

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/androidx/car/app/model/signin/SignInTemplate.SignInMethod`. The caller is expected to call `https://developer.android.com/reference/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)

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

Sets the title of the template.

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

Only `https://developer.android.com/reference/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/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 |