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

*** ** * ** ***

<br />

```
class NavigationTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate` | `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate` defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` with a list of template-scoped actions for this template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setBackgroundColor(androidx.car.app.model.CarColor)(backgroundColor: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor)` Sets the background color to use for the navigation information. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate)(destinationTravelEstimate: https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate` to the final destination. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 2) https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip)(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` with a list of map-control related actions for this template, such as pan or zoom. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setNavigationInfo(androidx.car.app.navigation.model.NavigationTemplate.NavigationInfo)(navigationInfo: https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.NavigationInfo)` Sets the navigation information to display on the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 2) https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener)(panModeListener: https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/PanModeListener)` Sets a `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/PanModeListener` that notifies when the user enters and exits the pan mode. |

## Public constructors

### Builder

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

```
Builder()
```

Constructs an empty `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/NavigationTemplate.Builder` instance.

## Public functions

### build

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

```
fun build(): NavigationTemplate
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` is not set on this template |

### setActionStrip

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

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

Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` with a list of template-scoped actions for this template.

The `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead.

#### Requirements

This template allows up to 4 `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 4 allowed `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s, it can either be a title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`, or a icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)`.

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

### setBackgroundColor

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

```
fun setBackgroundColor(backgroundColor: CarColor): NavigationTemplate.Builder
```

Sets the background color to use for the navigation information.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

### setDestinationTravelEstimate

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

```
fun setDestinationTravelEstimate(destinationTravelEstimate: TravelEstimate): NavigationTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate` to the final destination.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate`'s remaining time is less than zero unless the value provided is `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `destinationTravelEstimate` is `null` |

### setMapActionStrip

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

```
@RequiresCarApi(value = 2)
fun setMapActionStrip(actionStrip: ActionStrip): NavigationTemplate.Builder
```

Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` with a list of map-control related actions for this template, such as pan or zoom.

The host will draw the buttons in an area that is associated with map controls.

If the app does not include the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#PAN()` button in this `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

#### Requirements

This template allows up to 4 `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s in its map `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`. Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s with icons set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)` are allowed.

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

### setNavigationInfo

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

```
fun setNavigationInfo(navigationInfo: NavigationTemplate.NavigationInfo): NavigationTemplate.Builder
```

Sets the navigation information to display on the template.

Unless set with this method, navigation info won't be displayed on the template.

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

### setPanModeListener

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

```
@RequiresCarApi(value = 2)
fun setPanModeListener(panModeListener: PanModeListener): NavigationTemplate.Builder
```

Sets a `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/PanModeListener` that notifies when the user enters and exits the pan mode.

If the app does not include the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#PAN()` button in the map `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

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