Android 12 Developer Preview is here! Try it out, and give us your feedback!

NavigationTemplate

public final class NavigationTemplate
extends Object implements Template

java.lang.Object
   ↳ androidx.car.app.navigation.model.NavigationTemplate


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 Screen.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 AppManager.setSurfaceCallback(SurfaceCallback).

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

Template Restrictions

In regard to template refreshes, as described in Screen.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 classes

class NavigationTemplate.Builder

A builder of NavigationTemplate

interface NavigationTemplate.NavigationInfo

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

Public methods

boolean equals(Object other)
ActionStrip getActionStrip()

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

CarColor getBackgroundColor()

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

TravelEstimate getDestinationTravelEstimate()

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

NavigationTemplate.NavigationInfo getNavigationInfo()

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

int hashCode()
String toString()

Inherited methods

Public methods

equals

public boolean equals (Object other)

Parameters
other Object

Returns
boolean

getActionStrip

public ActionStrip getActionStrip ()

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

Returns
ActionStrip

getBackgroundColor

public CarColor getBackgroundColor ()

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

Returns
CarColor

getDestinationTravelEstimate

public TravelEstimate getDestinationTravelEstimate ()

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

Returns
TravelEstimate

getNavigationInfo

public NavigationTemplate.NavigationInfo getNavigationInfo ()

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

Returns
NavigationTemplate.NavigationInfo

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String