Destination.Builder

public static final class Destination.Builder
extends Object

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


A builder of Destination.

Summary

Public constructors

Builder()

Returns an empty Destination.Builder instance.

Public methods

Destination build()

Constructs the Destination defined by this builder.

Destination.Builder setAddress(CharSequence address)

Sets the destination address formatted for the user's current locale.

Destination.Builder setImage(CarIcon image)

Sets the destination image to display.

Destination.Builder setName(CharSequence name)

Sets the destination name formatted for the user's current locale.

Inherited methods

Public constructors

Builder

public Builder ()

Returns an empty Destination.Builder instance.

Public methods

build

public Destination build ()

Constructs the Destination defined by this builder.

At least one of the name or the address must be set and not empty.

Returns
Destination

Throws
IllegalStateException if both the name and the address are null or empty.

setAddress

public Destination.Builder setAddress (CharSequence address)

Sets the destination address formatted for the user's current locale.

Spans are not supported in the input string and will be ignored.

Parameters
address CharSequence

Returns
Destination.Builder

Throws
NullPointerException if address is null

See also:

setImage

public Destination.Builder setImage (CarIcon image)

Sets the destination image to display.

Image Sizing Guidance

To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 128 x 128 dp bounding box. If the image exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving the aspect ratio.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Parameters
image CarIcon

Returns
Destination.Builder

Throws
NullPointerException if image is null

setName

public Destination.Builder setName (CharSequence name)

Sets the destination name formatted for the user's current locale.

Spans are not supported in the input string and will be ignored.

Parameters
name CharSequence

Returns
Destination.Builder

Throws
NullPointerException if name is null

See also: