# DialogInterface

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/content/DialogInterface#nestedclasses)\|[Constants](https://developer.android.com/reference/android/content/DialogInterface#constants)\|[Methods](https://developer.android.com/reference/android/content/DialogInterface#pubmethods)  

# DialogInterface

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/content/DialogInterface "View this page in Kotlin")\|Java

`
public


interface
DialogInterface
`  
`


`

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

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [AlertDialog](https://developer.android.com/reference/android/app/AlertDialog),[CharacterPickerDialog](https://developer.android.com/reference/android/text/method/CharacterPickerDialog),[DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog),[Dialog](https://developer.android.com/reference/android/app/Dialog),[MockDialogInterface](https://developer.android.com/reference/android/test/mock/MockDialogInterface),[Presentation](https://developer.android.com/reference/android/app/Presentation),[ProgressDialog](https://developer.android.com/reference/android/app/ProgressDialog),[TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) |------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AlertDialog](https://developer.android.com/reference/android/app/AlertDialog)                             | A subclass of Dialog that can display one, two or three buttons.                                                                                                                                                                                                                                                                                                                                                                                                                                  | | [CharacterPickerDialog](https://developer.android.com/reference/android/text/method/CharacterPickerDialog) | Dialog for choosing accented characters related to a base character.                                                                                                                                                                                                                                                                                                                                                                                                                              | | [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog)                   | A simple dialog containing an[DatePicker](https://developer.android.com/reference/android/widget/DatePicker).                                                                                                                                                                                                                                                                                                                                                                                     | | [Dialog](https://developer.android.com/reference/android/app/Dialog)                                       | Base class for Dialogs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | [MockDialogInterface](https://developer.android.com/reference/android/test/mock/MockDialogInterface)       | *This class was deprecated in API level 24. Use a mocking framework like[Mockito](https://github.com/mockito/mockito). New tests should be written using the[Android Testing Support Library](https://developer.android.com/tools/testing-support-library).*                                                                                                                                                                                                                                      | | [Presentation](https://developer.android.com/reference/android/app/Presentation)                           | Base class for presentations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [ProgressDialog](https://developer.android.com/reference/android/app/ProgressDialog)                       | *This class was deprecated in API level 26.`ProgressDialog`is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like[ProgressBar](https://developer.android.com/reference/android/widget/ProgressBar), which can be embedded in your app's UI. Alternatively, you can use a[notification](https://developer.android.com/guide/topics/ui/notifiers/notifications)to inform the user of the task's progress.* | | [TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog)                   | A dialog that prompts the user for the time of day using a[TimePicker](https://developer.android.com/reference/android/widget/TimePicker).                                                                                                                                                                                                                                                                                                                                                        | |

<br />

*** ** * ** ***

Interface that defines a dialog-type class that can be shown, dismissed, or canceled, and may have buttons that can be clicked.

## Summary

|                                                                                                                                ### Nested classes                                                                                                                                 ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener) Interface used to allow the creator of a dialog to run some code when the dialog is canceled.                                          |
| ` interface` | [DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener) Interface used to allow the creator of a dialog to run some code when an item on the dialog is clicked.                                  |
| ` interface` | [DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener) Interface used to allow the creator of a dialog to run some code when the dialog is dismissed.                                       |
| ` interface` | [DialogInterface.OnKeyListener](https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener) Interface definition for a callback to be invoked when a key event is dispatched to this dialog.                                             |
| ` interface` | [DialogInterface.OnMultiChoiceClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener) Interface used to allow the creator of a dialog to run some code when an item in a multi-choice dialog is clicked. |
| ` interface` | [DialogInterface.OnShowListener](https://developer.android.com/reference/android/content/DialogInterface.OnShowListener) Interface used to allow the creator of a dialog to run some code when the dialog is shown.                                                 |

|                                                                                                                          ### Constants                                                                                                                          ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [BUTTON1](https://developer.android.com/reference/android/content/DialogInterface#BUTTON1) *This constant was deprecated in API level 15. Use[BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE)* |
| `int` | [BUTTON2](https://developer.android.com/reference/android/content/DialogInterface#BUTTON2) *This constant was deprecated in API level 15. Use[BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE)* |
| `int` | [BUTTON3](https://developer.android.com/reference/android/content/DialogInterface#BUTTON3) *This constant was deprecated in API level 15. Use[BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL)*   |
| `int` | [BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE) The identifier for the negative button.                                                                                                       |
| `int` | [BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL) The identifier for the neutral button.                                                                                                          |
| `int` | [BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE) The identifier for the positive button.                                                                                                       |

|                                                                                                                            ### Public methods                                                                                                                            ||
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void` | ` `[cancel](https://developer.android.com/reference/android/content/DialogInterface#cancel())`() ` Cancels the dialog, invoking the[OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener).       |
| ` abstract void` | ` `[dismiss](https://developer.android.com/reference/android/content/DialogInterface#dismiss())`() ` Dismisses the dialog, invoking the[OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener). |

## Constants

### BUTTON1

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

```
public static final int BUTTON1
```

<br />

**This constant was deprecated in API level 15.**   
Use[BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE)

<br />

<br />

Constant Value: -1 (0xffffffff)  

### BUTTON2

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

```
public static final int BUTTON2
```

<br />

**This constant was deprecated in API level 15.**   
Use[BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE)

<br />

<br />

Constant Value: -2 (0xfffffffe)  

### BUTTON3

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

```
public static final int BUTTON3
```

<br />

**This constant was deprecated in API level 15.**   
Use[BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL)

<br />

<br />

Constant Value: -3 (0xfffffffd)  

### BUTTON_NEGATIVE

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

```
public static final int BUTTON_NEGATIVE
```

The identifier for the negative button.

<br />

Constant Value: -2 (0xfffffffe)  

### BUTTON_NEUTRAL

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

```
public static final int BUTTON_NEUTRAL
```

The identifier for the neutral button.

<br />

Constant Value: -3 (0xfffffffd)  

### BUTTON_POSITIVE

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

```
public static final int BUTTON_POSITIVE
```

The identifier for the positive button.

<br />

Constant Value: -1 (0xffffffff)

## Public methods

### cancel

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

```
public abstract void cancel ()
```

Cancels the dialog, invoking the[OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener).

The[OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener)may also be called if cancellation dismisses the dialog.

<br />

### dismiss

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

```
public abstract void dismiss ()
```

Dismisses the dialog, invoking the[OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener).

<br />