Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener#pubmethods)

# DialogInterface.OnCancelListener

*** ** * ** ***


`
public
static


interface
DialogInterface.OnCancelListener
`


`


`

|---|
| android.content.DialogInterface.OnCancelListener |

|---|
| Known indirect subclasses [DialogFragment](https://developer.android.com/reference/android/app/DialogFragment), [SearchManager](https://developer.android.com/reference/android/app/SearchManager) |---|---| | [DialogFragment](https://developer.android.com/reference/android/app/DialogFragment) | *This class was deprecated in API level 28. Use the [Support Library](https://developer.android.com/tools/extras/support-library) `https://developer.android.com/reference/androidx/fragment/app/DialogFragment.html` for consistent behavior across all devices and access to [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle).* | | [SearchManager](https://developer.android.com/reference/android/app/SearchManager) | This class provides access to the system search services. | |

<br />

*** ** * ** ***

Interface used to allow the creator of a dialog to run some code when the
dialog is canceled.


This will only be called when the dialog is canceled, if the creator
needs to know when it is dismissed in general, use
`https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener`.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener#onCancel(android.content.DialogInterface)(https://developer.android.com/reference/android/content/DialogInterface dialog) ` This method will be invoked when the dialog is canceled. |

## Public methods

### onCancel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onCancel (DialogInterface dialog)
```

This method will be invoked when the dialog is canceled.

<br />

| Parameters ||
|---|---|
| `dialog` | `DialogInterface`: the dialog that was canceled will be passed into the method <br /> |