# Alert

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/car/app/model/Alert "View this page in Java")

<br />

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

<br />

*** ** * ** ***

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

## Summary

|                                                                                                ### Nested types                                                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[Alert.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert.Builder) A builder of[Alert](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert). |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DURATION_SHOW_INDEFINITELY](https://developer.android.com/reference/kotlin/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 functions                                                                                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                              | [equals](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#equals(java.lang.Object))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)`                                                                                                       |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Action](https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)`!>` | [getActions](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getActions())`()` Returns the[List](https://developer.android.com/reference/java/util/List.html)of[Action](https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)s associated with the alert. |
| [AlertCallbackDelegate](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallbackDelegate)`?`                                                                                                                                                                          | [getCallbackDelegate](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getCallbackDelegate())`()` Returns the[AlertCallbackDelegate](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallbackDelegate)that should be used for this alert.               |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                                                                                                                                                    | [getDurationMillis](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getDurationMillis())`()` Returns the maximum duration in milli seconds for which the alert can be shown.                                                                                                      |
| [CarIcon](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)`?`                                                                                                                                                                                                      | [getIcon](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getIcon())`()` Returns the[CarIcon](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)to display in the alert or`null`if the alert does not have an icon.                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                      | [getId](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getId())`()` Returns the id of the alert.                                                                                                                                                                                 |
| [CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)`?`                                                                                                                                                                                                      | [getSubtitle](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getSubtitle())`()` Returns the subtitle displayed in the alert or`null`if the alert does not have a subtitle.                                                                                                       |
| [CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)                                                                                                                                                                                                         | [getTitle](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#getTitle())`()` Returns the title displayed in the alert.                                                                                                                                                              |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                      | [hashCode](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert#hashCode())`()`                                                                                                                                                                                                        |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                                                                                                | [toString](https://developer.android.com/reference/kotlin/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)  

```
const val DURATION_SHOW_INDEFINITELY = 2147483647: Int
```

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

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```  

### getActions

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

```
fun getActions(): (Mutable)List<Action!>
```

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

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [addAction](https://developer.android.com/reference/kotlin/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)  

```
fun getCallbackDelegate(): AlertCallbackDelegate?
```

Returns the[AlertCallbackDelegate](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallbackDelegate)that should be used for this alert.  

|                                               See also                                               |
|------------------------------------------------------------------------------------------------------|---|
| [Alert.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert.Builder) |   |

### getDurationMillis

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

```
fun getDurationMillis(): Long
```

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)  

```
fun getIcon(): CarIcon?
```

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

|                                                                See also                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------|---|
| [setIcon](https://developer.android.com/reference/kotlin/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)  

```
fun getId(): Int
```

Returns the id of the alert.  

### getSubtitle

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

```
fun getSubtitle(): CarText?
```

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

|                                                                    See also                                                                    |
|------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setSubtitle](https://developer.android.com/reference/kotlin/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)  

```
fun getTitle(): CarText
```

Returns the title displayed in the alert.  

### hashCode

```
fun hashCode(): Int
```  

### toString

```
fun toString(): String
```