MessageInfo.Builder

public static final class MessageInfo.Builder
extends Object

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


A builder of MessageInfo.

Summary

Public constructors

Builder(CharSequence title)

Returns a new instance of a MessageInfo.Builder.

Builder(CarText title)

Returns a new instance of a MessageInfo.Builder.

Public methods

MessageInfo build()

Constructs the MessageInfo defined by this builder.

MessageInfo.Builder setImage(CarIcon image)

Sets the image to display along with the message.

MessageInfo.Builder setText(CharSequence text)

Sets additional text on the message.

MessageInfo.Builder setText(CarText text)

Sets additional text on the message, with support for multiple length variants.

MessageInfo.Builder setTitle(CharSequence title)

Sets the title of the message.

Inherited methods

Public constructors

Builder

public Builder (CharSequence title)

Returns a new instance of a MessageInfo.Builder.

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
title CharSequence

Throws
NullPointerException if title is null
IllegalArgumentException if title contains unsupported spans

Builder

public Builder (CarText title)

Returns a new instance of a MessageInfo.Builder.

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

Parameters
title CarText

Throws
NullPointerException if title is null

Public methods

build

public MessageInfo build ()

Constructs the MessageInfo defined by this builder.

Returns
MessageInfo

setImage

public MessageInfo.Builder setImage (CarIcon image)

Sets the image to display along with the message.

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
MessageInfo.Builder

Throws
NullPointerException if image is null

setText

public MessageInfo.Builder setText (CharSequence text)

Sets additional text on the message.

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
text CharSequence

Returns
MessageInfo.Builder

Throws
NullPointerException if text is null
IllegalArgumentException if text contains unsupported spans

See also:

setText

public MessageInfo.Builder setText (CarText text)

Sets additional text on the message, with support for multiple length variants.

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
text CarText

Returns
MessageInfo.Builder

Throws
NullPointerException if text is null
IllegalArgumentException if text contains unsupported spans

See also:

setTitle

public MessageInfo.Builder setTitle (CharSequence title)

Sets the title of the message.

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
title CharSequence

Returns
MessageInfo.Builder

Throws
NullPointerException if title is null
IllegalArgumentException if title contains unsupported spans

See also: