# Alert

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/Alert.java+class:androidx.car.app.model.Alert) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 5)
public final class Alert
```

<br />

*** ** * ** ***

Represents an alert with an optional icon, subtitle and actions.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/Alert.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/Alert`. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/Alert#DURATION_SHOW_INDEFINITELY() = 2147483647` By setting the alert duration to this value, the progress bar (timer) on the alert will not be shown. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Alert#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/car/app/model/Action>` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getActions()()` Returns the `https://developer.android.com/reference/java/util/List.html` of `https://developer.android.com/reference/androidx/car/app/model/Action`s associated with the alert. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/AlertCallbackDelegate` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getCallbackDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/AlertCallbackDelegate` that should be used for this alert. |
| `long` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getDurationMillis()()` Returns the maximum duration in milli seconds for which the alert can be shown. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarIcon` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getIcon()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` to display in the alert or `null` if the alert does not have an icon. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getId()()` Returns the id of the alert. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getSubtitle()()` Returns the subtitle displayed in the alert or `null` if the alert does not have a subtitle. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Alert#getTitle()()` Returns the title displayed in the alert. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Alert#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/Alert#toString()()` |

## Constants

### DURATION_SHOW_INDEFINITELY

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public static final int DURATION_SHOW_INDEFINITELY = 2147483647
```

By setting the alert duration to this value, the progress bar (timer) on the alert will not be shown.

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getActions

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public @NonNull List<Action> getActions()
```

Returns the `https://developer.android.com/reference/java/util/List.html` of `https://developer.android.com/reference/androidx/car/app/model/Action`s associated with the alert.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Alert.Builder#addAction(androidx.car.app.model.Action)` |   |

### getCallbackDelegate

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public @Nullable AlertCallbackDelegate getCallbackDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/AlertCallbackDelegate` that should be used for this alert.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Alert.Builder` |   |

### getDurationMillis

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public long getDurationMillis()
```

Returns the maximum duration in milli seconds for which the alert can be shown.

### getIcon

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public @Nullable CarIcon getIcon()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` to display in the alert or `null` if the alert does not have an icon.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Alert.Builder#setIcon(androidx.car.app.model.CarIcon)` |   |

### getId

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public int getId()
```

Returns the id of the alert.

### getSubtitle

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public @Nullable CarText getSubtitle()
```

Returns the subtitle displayed in the alert or `null` if the alert does not have a subtitle.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Alert.Builder#setSubtitle(androidx.car.app.model.CarText)` |   |

### getTitle

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0)

```
public @NonNull CarText getTitle()
```

Returns the title displayed in the alert.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```