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

```
public final class NavigationTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate` | `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.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 an `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` with a list of template-scoped actions for this template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#setBackgroundColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarColor backgroundColor)` Sets the background color to use for the navigation information. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#setDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate destinationTravelEstimate )` Sets the `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` to the final destination. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 2) https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#setMapActionStrip(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 an `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` with a list of map-control related actions for this template, such as pan or zoom. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#setNavigationInfo(androidx.car.app.navigation.model.NavigationTemplate.NavigationInfo)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.NavigationInfo navigationInfo )` Sets the navigation information to display on the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 2) https://developer.android.com/reference/androidx/car/app/navigation/model/NavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener panModeListener)` Sets a `https://developer.android.com/reference/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)

```
public Builder()
```

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

## Public methods

### build

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

```
public @NonNull NavigationTemplate build()
```

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

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

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

The `https://developer.android.com/reference/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/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/androidx/car/app/model/Action`s instead.

#### Requirements

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

```
public @NonNull NavigationTemplate.Builder setBackgroundColor(@NonNull CarColor backgroundColor)
```

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)

```
public @NonNull NavigationTemplate.Builder setDestinationTravelEstimate(
    @NonNull TravelEstimate destinationTravelEstimate
)
```

Sets the `https://developer.android.com/reference/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/androidx/car/app/navigation/model/TravelEstimate`'s remaining time is less than zero unless the value provided is `https://developer.android.com/reference/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)
public @NonNull NavigationTemplate.Builder setMapActionStrip(@NonNull ActionStrip actionStrip)
```

Sets an `https://developer.android.com/reference/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/androidx/car/app/model/Action#PAN()` button in this `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/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/androidx/car/app/model/Action`s in its map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Only `https://developer.android.com/reference/androidx/car/app/model/Action`s with icons set via `https://developer.android.com/reference/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)

```
public @NonNull NavigationTemplate.Builder setNavigationInfo(
    @NonNull NavigationTemplate.NavigationInfo navigationInfo
)
```

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)
public @NonNull NavigationTemplate.Builder setPanModeListener(@NonNull PanModeListener panModeListener)
```

Sets a `https://developer.android.com/reference/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/androidx/car/app/model/Action#PAN()` button in the map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/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` |