Alert.Builder
public final class Alert.Builder
A builder of Alert.
Summary
Public constructors |
|---|
|
Creates an |
Public methods |
|
|---|---|
@NonNull Alert.Builder |
Adds the |
@NonNull Alert |
build()Constructs the |
@NonNull Alert.Builder |
setCallback(@NonNull AlertCallback callback)Sets the |
@NonNull Alert.Builder |
Sets the icon to display in the alert. |
@NonNull Alert.Builder |
setSubtitle(@NonNull CarText subtitle)Sets the subtitle to display in the alert, with support for multiple length variants. |
Public constructors
Builder
public Builder(int alertId, @NonNull CarText title, long durationMillis)
Creates an Builder instance.
Text spans are supported.
| Parameters | |
|---|---|
int alertId |
The unique identifier used for the alert. Alerts with the same id are considered equal. |
@NonNull CarText title |
The title of the alert. |
long durationMillis |
The maximum duration the alert can be shown in milli seconds. |
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
Public methods
addAction
public @NonNull Alert.Builder addAction(@NonNull Action action)
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. |
setCallback
public @NonNull Alert.Builder setCallback(@NonNull AlertCallback callback)
Sets the AlertCallback to receive alert related events.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
setIcon
public @NonNull Alert.Builder setIcon(@NonNull 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.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
setSubtitle
public @NonNull Alert.Builder setSubtitle(@NonNull CarText subtitle)
Sets the subtitle to display in the alert, with support for multiple length variants.
Text spans are supported.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
| See also | |
|---|---|
CarText |