# AlertCallback

# AlertCallback

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/AlertCallback.java+class:androidx.car.app.model.AlertCallback)  
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/AlertCallback "View this page in Java")

<br />

```
@CarProtocol
@RequiresCarApi(value = 5)
interface AlertCallback
```

<br />

*** ** * ** ***

A listener of dismiss events.

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [REASON_NOT_SUPPORTED](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallback#REASON_NOT_SUPPORTED())` = 3` Indicates the cancellation is due to the request not being supported, e.g. when current template cannot display the alert. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [REASON_TIMEOUT](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallback#REASON_TIMEOUT())` = 1` Indicates the cancellation is due to timeout.                                                                                          |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [REASON_USER_ACTION](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallback#REASON_USER_ACTION())` = 2` Indicates the cancellation is due to user generated action, e.g. close button being pressed.                                   |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onCancel](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallback#onCancel(int))`(reason: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies that a cancel event happened with given`reason`. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onDismiss](https://developer.android.com/reference/kotlin/androidx/car/app/model/AlertCallback#onDismiss())`()` Notifies that a dismiss happened.                                                                                                               |

## Constants

### REASON_NOT_SUPPORTED

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

```
const val REASON_NOT_SUPPORTED = 3: Int
```

Indicates the cancellation is due to the request not being supported, e.g. when current template cannot display the alert.  

### REASON_TIMEOUT

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

```
const val REASON_TIMEOUT = 1: Int
```

Indicates the cancellation is due to timeout.  

### REASON_USER_ACTION

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

```
const val REASON_USER_ACTION = 2: Int
```

Indicates the cancellation is due to user generated action, e.g. close button being pressed.  

## Public functions

### onCancel

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

```
fun onCancel(reason: Int): Unit
```

Notifies that a cancel event happened with given`reason`.  

### onDismiss

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

```
fun onDismiss(): Unit
```

Notifies that a dismiss happened.