LongMessageTemplate.Builder


@RequiresCarApi(value = 2)
class LongMessageTemplate.Builder


A builder of LongMessageTemplate.

Summary

Public constructors

Returns a Builder instance.

Public functions

LongMessageTemplate.Builder
addAction(action: Action)

Adds an Action to display along with the message.

LongMessageTemplate

Constructs the LongMessageTemplate defined by this builder.

LongMessageTemplate.Builder

Sets the ActionStrip for this template or null to not display an .

LongMessageTemplate.Builder
setHeaderAction(headerAction: Action)

Sets the Action that will be displayed in the header of the template.

LongMessageTemplate.Builder

Sets the title of the template.

Public constructors

Builder

Added in 1.1.0
Builder(message: CharSequence)

Returns a Builder instance.

Parameters
message: CharSequence

the text message to display in the template. This message will only be displayed when the car is parked.

Throws
java.lang.NullPointerException

if the message is null

Public functions

addAction

Added in 1.1.0
fun addAction(action: Action): LongMessageTemplate.Builder

Adds an Action to display along with the message.

Requirements This template allows up to 2 Actions in its body, and they must use a androidx.car.app.model.ParkedOnlyOnClickListener. One of these actions can be declared as primary via setFlags. Each action's title color can be customized with ForegroundCarColorSpan instances. Any other span is not supported.
Throws
java.lang.IllegalArgumentException

if action does not meet the requirements

java.lang.NullPointerException

if action is null

build

Added in 1.1.0
fun build(): LongMessageTemplate

Constructs the LongMessageTemplate defined by this builder.

Requirements A non-empty message must be set on the template.

If none of the header Action, the header title or the action strip have been set on the template, the header is hidden.

Throws
java.lang.IllegalStateException

if the message is empty

setActionStrip

Added in 1.1.0
fun setActionStrip(actionStrip: ActionStrip): LongMessageTemplate.Builder

Sets the ActionStrip for this template or null to not display an .

Unless set with this method, the template will not have an action strip.

Requirements This template allows up to 2 Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via setTitle. Otherwise, only Actions with icons are allowed.
Throws
java.lang.IllegalArgumentException

if actionStrip does not meet the requirements

java.lang.NullPointerException

if actionStrip is null

setHeaderAction

Added in 1.1.0
fun setHeaderAction(headerAction: Action): LongMessageTemplate.Builder

Sets the Action that will be displayed in the header of the template.

Unless set with this method, the template will not have a header action.

Requirements This template only supports either one of APP_ICON and BACK as a header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the template's requirements

java.lang.NullPointerException

if headerAction is null

setTitle

Added in 1.1.0
fun setTitle(title: CharSequence): LongMessageTemplate.Builder

Sets the title of the template.

Unless set with this method, the template will not have a title.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText