Alert.Builder

class Alert.Builder


A builder of Alert.

Summary

Public constructors

Builder(alertId: Int, title: CarText, durationMillis: Long)

Creates an Builder instance.

Public functions

Alert.Builder
addAction(action: Action)

Adds the action to the list of actions on the alert.

Alert

Constructs the Alert defined by this builder.

Alert.Builder

Sets the AlertCallback to receive alert related events.

Alert.Builder

Sets the icon to display in the alert.

Alert.Builder
setSubtitle(subtitle: CarText)

Sets the subtitle to display in the alert, with support for multiple length variants.

Public constructors

Builder

Added in 1.2.0
Builder(alertId: Int, title: CarText, durationMillis: Long)

Creates an Builder instance.

Text spans are supported.

Parameters
alertId: Int

The unique identifier used for the alert. Alerts with the same id are considered equal.

title: CarText

The title of the alert.

durationMillis: Long

The maximum duration the alert can be shown in milli seconds.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if duration is not positive

See also
CarText

Public functions

addAction

Added in 1.2.0
fun addAction(action: Action): Alert.Builder

Adds the action to the list of actions on the alert.

An alert can have up to 2 actions.

Throws
java.lang.IllegalStateException

if more than 2 actions are added.

build

Added in 1.2.0
fun build(): Alert

Constructs the Alert defined by this builder.

setCallback

Added in 1.2.0
fun setCallback(callback: AlertCallback): Alert.Builder

Sets the AlertCallback to receive alert related events.

Throws
java.lang.NullPointerException

if callback is null

setIcon

Added in 1.2.0
fun setIcon(icon: CarIcon): Alert.Builder

Sets the icon to display in the alert.

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

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

Throws
java.lang.NullPointerException

if icon is null

setSubtitle

Added in 1.2.0
fun setSubtitle(subtitle: CarText): Alert.Builder

Sets the subtitle to display in the alert, with support for multiple length variants.

Text spans are supported.

Throws
java.lang.NullPointerException

if subtitle is null

See also
CarText