# RoutePreviewNavigationTemplate

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

*** ** * ** ***


```
@CarProtocol
public final class RoutePreviewNavigationTemplate implements Template
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Deprecated in Java

A template that supports showing a list of routes alongside a custom drawn map.

The list must have its `https://developer.android.com/reference/androidx/car/app/model/ItemList.OnSelectedListener` set, and the template must have its navigate action set (see `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setNavigateAction(androidx.car.app.model.Action)`). These are used in conjunction to inform the app that:

1. A route has been selected. The app should also highlight the route on the map surface.
2. A navigate action has been triggered. The app should begin navigation using the selected route.

The template itself does not expose a drawing surface. In order to draw on the canvas, use `https://developer.android.com/reference/androidx/car/app/AppManager#setSurfaceCallback(androidx.car.app.SurfaceCallback)`.

#### Template Restrictions

In regards to template refreshes, as described in `https://developer.android.com/reference/androidx/car/app/Screen#onGetTemplate()`, this template is considered a refresh of a previous one if:

- The previous template is in a loading state (see `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setLoading(boolean)`, or
- The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new `https://developer.android.com/reference/androidx/car/app/model/ItemList`s have not changed.

Note that specifically, this means the app should not use this template to continuously refresh the routes as the car moves.

In order to use this template your car app **MUST** declare that it uses the `
androidx.car.app.NAVIGATION_TEMPLATES` permission in the manifest.
For instance, using the deprecated `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate`, if the template was:

```
RoutePreviewNavigationTemplate template = new RoutePreviewNavigationTemplate
 .Builder()
         .setItemList(new ItemList.Builder()
                 .addItem(new Row.Builder()
                     .setTitle(title))
                     .build())
                 .build())
         .setHeader(header)
         .setNavigateAction(new Action.Builder()
                 .setTitle("drive")
                 .setOnClickListener(() -> {})
                 .build())
         .setActionStrip(actionStrip)
         .setMapActionStrip(mapActionStrip)
         .build();
```
The Navigate Action in RoutePreview is added as a secondary action for each row. Using the new `https://developer.android.com/reference/androidx/car/app/navigation/model/MapWithContentTemplate`, the template would be:

```
MapWithContentTemplate template = new MapWithContentTemplate.Builder()
             .setContentTemplate(new ListTemplate.Builder()
                    .setSingleList(new ItemList.Builder()
                         .addItem(new Row.Builder()
                              .setTitle(title))
                              .addAction(new Action.Builder()
                                     .setTitle("drive")
                                     .setOnClickListener(() -> {})
                                     .build())
                              .build())
                         .build()))
                    .setHeader(header)
                    .build())
             .setActionStrip(actionStrip)
             .setMapController(new MapController.Builder()
                   .setMapActionStrip(mapActionStrip)
                   .build())
             .build();
```
@deprecated with API 7. Use the `https://developer.android.com/reference/androidx/car/app/navigation/model/MapWithContentTemplate` API instead.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` **This class is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `boolean` | `[equals](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#equals(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip` | `[getActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getActionStrip())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Header` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 5) [getHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Action` | `[getHeaderAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeaderAction())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader()` <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ItemList` | `[getItemList](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getItemList())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 4) [getMapActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getMapActionStrip())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Action` | `[getNavigateAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getNavigateAction())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeDelegate` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 4) [getPanModeDelegate](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getPanModeDelegate())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `[getTitle](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getTitle())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader()` <br /> |
| `int` | `[hashCode](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#hashCode())()` **This method is deprecated.** Deprecated in Java |
| `boolean` | `[isLoading](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#isLoading())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `[toString](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#toString())()` **This method is deprecated.** Deprecated in Java |

## Public methods

### equals

```
public boolean [equals](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#equals(java.lang.Object))(@Nullable Object other)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

### getActionStrip

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

```
public @Nullable ActionStrip [getActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getActionStrip())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)` |   |

### getHeader

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

```
@RequiresCarApi(value = 5)
public @Nullable Header [getHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the `https://developer.android.com/reference/androidx/car/app/model/Header` to display in this template.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` |   |

### getHeaderAction

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

```
public @Nullable Action [getHeaderAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeaderAction())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader()`

Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` that is set to be displayed in the header of the template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)` |   |

### getItemList

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

```
public @Nullable ItemList [getItemList](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getItemList())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the `https://developer.android.com/reference/androidx/car/app/model/ItemList` to show route options in a list view along with the map or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setItemList(androidx.car.app.model.ItemList)` |   |

### getMapActionStrip

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

```
@RequiresCarApi(value = 4)
public @Nullable ActionStrip [getMapActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getMapActionStrip())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip)` |   |

### getNavigateAction

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

```
public @Nullable Action [getNavigateAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getNavigateAction())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` to allow users to request navigation using the currently selected route or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setNavigateAction(androidx.car.app.model.Action)` |   |

### getPanModeDelegate

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

```
@RequiresCarApi(value = 4)
public @Nullable PanModeDelegate [getPanModeDelegate](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getPanModeDelegate())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the `https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeDelegate` that should be called when the user interacts with pan mode on this template, or `null` if a `https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener` was not set.

### getTitle

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

```
public @Nullable CarText [getTitle](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getTitle())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#getHeader()`

Returns the title of the template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(java.lang.CharSequence)` |   |

### hashCode

```
public int [hashCode](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#hashCode())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

### isLoading

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

```
public boolean [isLoading](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#isLoading())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns whether the template is loading.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setLoading(boolean)` |   |

### toString

```
public @NonNull String [toString](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate#toString())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java