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

NavigationTemplate.Builder

public static final class NavigationTemplate.Builder
extends Object

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


A builder of NavigationTemplate.

Summary

Public constructors

Builder()

Constructs an empty NavigationTemplate.Builder instance.

Public methods

NavigationTemplate build()

Constructs the NavigationTemplate defined by this builder.

NavigationTemplate.Builder setActionStrip(ActionStrip actionStrip)

Sets an ActionStrip with a list of template-scoped actions for this template.

NavigationTemplate.Builder setBackgroundColor(CarColor backgroundColor)

Sets the background color to use for the navigation information.

NavigationTemplate.Builder setDestinationTravelEstimate(TravelEstimate destinationTravelEstimate)

Sets the TravelEstimate to the final destination.

NavigationTemplate.Builder setNavigationInfo(NavigationTemplate.NavigationInfo navigationInfo)

Sets the navigation information to display on the template.

Inherited methods

Public constructors

Builder

public Builder ()

Constructs an empty NavigationTemplate.Builder instance.

Public methods

build

public NavigationTemplate build ()

Constructs the NavigationTemplate defined by this builder.

Returns
NavigationTemplate

Throws
IllegalStateException if an ActionStrip is not set on this template

setActionStrip

public NavigationTemplate.Builder setActionStrip (ActionStrip actionStrip)

Sets an ActionStrip with a list of template-scoped actions for this template.

Requirements

Besides Action.APP_ICON and Action.BACK, this template requires at least 1 and up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, only one can contain a title as set via Action.Builder.setTitle(CarText). Otherwise, only Actions with icons are allowed.

Parameters
actionStrip ActionStrip

Returns
NavigationTemplate.Builder

Throws
IllegalArgumentException if actionStrip does not meet the template's requirements
NullPointerException if actionStrip is null

setBackgroundColor

public NavigationTemplate.Builder setBackgroundColor (CarColor backgroundColor)

Sets the background color to use for the navigation information.

The host may ignore this color and use a default color instead if the color does not pass the contrast requirements.

Parameters
backgroundColor CarColor

Returns
NavigationTemplate.Builder

setDestinationTravelEstimate

public NavigationTemplate.Builder setDestinationTravelEstimate (TravelEstimate destinationTravelEstimate)

Sets the TravelEstimate to the final destination.

Parameters
destinationTravelEstimate TravelEstimate

Returns
NavigationTemplate.Builder

Throws
IllegalArgumentException if the TravelEstimate's remaining time is less than zero
NullPointerException if destinationTravelEstimate is null

setNavigationInfo

public NavigationTemplate.Builder setNavigationInfo (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.

Parameters
navigationInfo NavigationTemplate.NavigationInfo

Returns
NavigationTemplate.Builder

Throws
NullPointerException if navigationInfo is null