public final class

Alert.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.Alert.Builder

Overview

A builder of Alert.

Summary

Constructors
publicBuilder(int alertId, CarText title, long durationMillis)

Creates an Alert.Builder instance.

Methods
public Alert.BuilderaddAction(Action action)

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

public Alertbuild()

Constructs the Alert defined by this builder.

public Alert.BuildersetCallback(AlertCallback callback)

Sets the AlertCallback to receive alert related events.

public Alert.BuildersetIcon(CarIcon icon)

Sets the icon to display in the alert.

public Alert.BuildersetSubtitle(CarText subtitle)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(int alertId, CarText title, long durationMillis)

Creates an Alert.Builder instance.

Text spans are supported.

Parameters:

alertId: The unique identifier used for the alert. Alerts with the same id are considered equal.
title: The title of the alert.
durationMillis: The maximum duration the alert can be shown in milli seconds.

See also: CarText

Methods

public Alert.Builder setSubtitle(CarText subtitle)

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

Text spans are supported.

See also: CarText

public Alert.Builder setIcon(CarIcon icon)

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.

public Alert.Builder addAction(Action action)

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

An alert can have up to 2 actions.

public Alert.Builder setCallback(AlertCallback callback)

Sets the AlertCallback to receive alert related events.

public Alert build()

Constructs the Alert defined by this builder.