NavigationTemplate


@CarProtocol
class NavigationTemplate : Template


A template for showing navigation information.

This template has two independent sections which can be updated:

  • Navigation information such as routing instructions or navigation-related messages.
  • Travel estimates to the destination.

To update the template as the user navigates, call invalidate to provide the host with a new template with the updated information.

The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.

See androidx.car.app.notification.CarAppExtender for how to show alerts with notifications. Frequent alert notifications distract the driver and are discouraged.

Pan and Zoom This template allows an app to provide pan and zoom functionality. To support pan and zoom, respond to the user input in SurfaceCallback methods, such as: In order to receive the callbacks, add an PAN button in a map ActionStrip via the setMapActionStrip method:
...
Action panAction = new Action.Builder(Action.PAN).setIcon(myPanIcon).build();
ActionStrip mapActionStrip = new ActionStrip.Builder().addAction(panAction).build();
NavigationTemplate.Builder builder = new NavigationTemplate.Builder();
builder.setMapActionStrip(mapActionStrip);
...
When the user presses the PAN button, the host enters the pan mode. In this mode, the host translates the user input from non-touch input devices, such as rotary controllers and touchpads, and calls the appropriate SurfaceCallback methods. Respond to the user action to enter or exit the pan mode via setPanModeListener.

If the app does not include this button in the map ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.

The host may hide the pan button in some head units in which the user does not need it. Also, the host may hide other UI components in the template while the user is in the pan mode.

Note that not all head units support touch gestures, and not all touch screens support multi-touch gestures. Therefore, some SurfaceCallback methods may not be called in some cars. In order to support different head units, use the buttons in the map action strip to provide necessary functionality, such as the zoom-in and zoom-out buttons.

Template Restrictions In regard to template refreshes, as described in onGetTemplate, this template supports any content changes as refreshes. This allows apps to interactively update the turn-by-turn instructions without the templates being counted against the template quota.

Further, this template is considered a view that the user will stay and consume contents from, and the host will reset the template quota once an app reaches this template.

In order to use this template your car app MUST declare that it uses the androidx.car.app.NAVIGATION_TEMPLATES permission in the manifest.

Summary

Nested types

A builder of NavigationTemplate.

Represents navigation information such as routing instructions or navigation-related messages.

Public functions

Boolean
equals(other: Any?)
ActionStrip?

Returns the ActionStrip for this template or null if not set.

CarColor?

Returns the background color used for the navigation information or null if set to the default value.

TravelEstimate?

Returns the TravelEstimate to the final destination or null if there is no travel estimate information.

ActionStrip?

Returns the map ActionStrip for this template or null if not set.

NavigationTemplate.NavigationInfo?

Returns the navigation information displayed on the template or null if there is no navigation information on top of the map.

PanModeDelegate?

Returns the PanModeDelegate that should be called when the user interacts with pan mode on this template, or null if a PanModeListener was not set.

Toggle?

This function is deprecated.

use getPanModeDelegate

Int
String

Public functions

equals

fun equals(other: Any?): Boolean

getActionStrip

Added in 1.0.0
fun getActionStrip(): ActionStrip?

Returns the ActionStrip for this template or null if not set.

See also
setActionStrip

getBackgroundColor

Added in 1.0.0
fun getBackgroundColor(): CarColor?

Returns the background color used for the navigation information or null if set to the default value.

getDestinationTravelEstimate

Added in 1.0.0
fun getDestinationTravelEstimate(): TravelEstimate?

Returns the TravelEstimate to the final destination or null if there is no travel estimate information.

getMapActionStrip

Added in 1.1.0
@RequiresCarApi(value = 2)
fun getMapActionStrip(): ActionStrip?

Returns the map ActionStrip for this template or null if not set.

getNavigationInfo

Added in 1.0.0
fun getNavigationInfo(): NavigationTemplate.NavigationInfo?

Returns the navigation information displayed on the template or null if there is no navigation information on top of the map.

getPanModeDelegate

Added in 1.1.0
@RequiresCarApi(value = 2)
fun getPanModeDelegate(): PanModeDelegate?

Returns the PanModeDelegate that should be called when the user interacts with pan mode on this template, or null if a PanModeListener was not set.

getPanModeToggle

Added in 1.1.0
Deprecated in 1.1.0
@RequiresCarApi(value = 2)
fun getPanModeToggle(): Toggle?

Returns whether this template is in the pan mode.

hashCode

fun hashCode(): Int

toString

fun toString(): String