# Dialog

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/app/Dialog#inhconstants)\|[Ctors](https://developer.android.com/reference/android/app/Dialog#pubctors)\|[Protected Ctors](https://developer.android.com/reference/android/app/Dialog#proctors)\|[Methods](https://developer.android.com/reference/android/app/Dialog#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/app/Dialog#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/Dialog#inhmethods)  

# Dialog

*** ** * ** ***

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

`
public


class
Dialog
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[DialogInterface](https://developer.android.com/reference/android/content/DialogInterface)`,

`[KeyEvent.Callback](https://developer.android.com/reference/android/view/KeyEvent.Callback)`,

`[View.OnCreateContextMenuListener](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener)`,

`[Window.Callback](https://developer.android.com/reference/android/view/Window.Callback)`


`

|---|--------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.Dialog |

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [AlertDialog](https://developer.android.com/reference/android/app/AlertDialog),[CharacterPickerDialog](https://developer.android.com/reference/android/text/method/CharacterPickerDialog),[Presentation](https://developer.android.com/reference/android/app/Presentation) |------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------| | [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. | | [Presentation](https://developer.android.com/reference/android/app/Presentation)                           | Base class for presentations.                                        | |

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog),[ProgressDialog](https://developer.android.com/reference/android/app/ProgressDialog),[TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) |------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog) | A simple dialog containing an[DatePicker](https://developer.android.com/reference/android/widget/DatePicker).                                                                                                                                                                                                                                                                                                                                                                                     | | [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 />

*** ** * ** ***

Base class for Dialogs.

Note: Activities provide a facility to manage the creation, saving and restoring of dialogs. See[Activity.onCreateDialog(int)](https://developer.android.com/reference/android/app/Activity#onCreateDialog(int)),[Activity.onPrepareDialog(int, Dialog)](https://developer.android.com/reference/android/app/Activity#onPrepareDialog(int,%20android.app.Dialog)),[Activity.showDialog(int)](https://developer.android.com/reference/android/app/Activity#showDialog(int)), and[Activity.dismissDialog(int)](https://developer.android.com/reference/android/app/Activity#dismissDialog(int)). If these methods are used,[getOwnerActivity()](https://developer.android.com/reference/android/app/Dialog#getOwnerActivity())will return the Activity that managed this dialog.

Often you will want to have a Dialog display on top of the current input method, because there is no reason for it to accept text. You can do this by setting the[WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM)window flag (assuming your Dialog takes input focus, as it the default) with the following code:  

```
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
         WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
```  

### Developer Guides

For more information about creating dialogs, read the[Dialogs](https://developer.android.com/guide/topics/ui/dialogs)developer guide.

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface) |-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `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 constructors                                                                                                                               ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Dialog](https://developer.android.com/reference/android/app/Dialog#Dialog(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Creates a dialog window that uses the default dialog theme.                     |
| ` `[Dialog](https://developer.android.com/reference/android/app/Dialog#Dialog(android.content.Context,%20int))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, int themeResId) ` Creates a dialog window that uses a custom dialog style. |

|                                                                                                                                                                                                      ### Protected constructors                                                                                                                                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Dialog](https://developer.android.com/reference/android/app/Dialog#Dialog(android.content.Context,%20boolean,%20android.content.DialogInterface.OnCancelListener))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, boolean cancelable, `[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)` cancelListener) ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                      | ` `[addContentView](https://developer.android.com/reference/android/app/Dialog#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams)` params) ` Add an additional content view to the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                                                      | ` `[cancel](https://developer.android.com/reference/android/app/Dialog#cancel())`() ` Cancel the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[closeOptionsMenu](https://developer.android.com/reference/android/app/Dialog#closeOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[create](https://developer.android.com/reference/android/app/Dialog#create())`() ` Forces immediate creation of the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                      | ` `[dismiss](https://developer.android.com/reference/android/app/Dialog#dismiss())`() ` Dismiss this dialog, removing it from the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` boolean`                                                                                                   | ` `[dispatchGenericMotionEvent](https://developer.android.com/reference/android/app/Dialog#dispatchGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process generic motion events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` boolean`                                                                                                   | ` `[dispatchKeyEvent](https://developer.android.com/reference/android/app/Dialog#dispatchKeyEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process key events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` boolean`                                                                                                   | ` `[dispatchKeyShortcutEvent](https://developer.android.com/reference/android/app/Dialog#dispatchKeyShortcutEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process a key shortcut event.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                   | ` `[dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/android/app/Dialog#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent))`(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)` event) ` Called to process population of[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)s.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` boolean`                                                                                                   | ` `[dispatchTouchEvent](https://developer.android.com/reference/android/app/Dialog#dispatchTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process touch screen events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                   | ` `[dispatchTrackballEvent](https://developer.android.com/reference/android/app/Dialog#dispatchTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process trackball events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` <T extends `[View](https://developer.android.com/reference/android/view/View)`> T`                         | ` `[findViewById](https://developer.android.com/reference/android/app/Dialog#findViewById(int))`(int id) ` Finds the first descendant view with the given ID or`null`if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[ActionBar](https://developer.android.com/reference/android/app/ActionBar)                                | ` `[getActionBar](https://developer.android.com/reference/android/app/Dialog#getActionBar())`() ` Retrieve the[ActionBar](https://developer.android.com/reference/android/app/ActionBar)attached to this dialog, if present.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` final `[Context](https://developer.android.com/reference/android/content/Context)                          | ` `[getContext](https://developer.android.com/reference/android/app/Dialog#getContext())`() ` Retrieve the Context this Dialog is running in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` `[View](https://developer.android.com/reference/android/view/View)                                         | ` `[getCurrentFocus](https://developer.android.com/reference/android/app/Dialog#getCurrentFocus())`() ` Call[Window.getCurrentFocus()](https://developer.android.com/reference/android/view/Window#getCurrentFocus())on the Window if this Activity to return the currently focused view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater)                     | ` `[getLayoutInflater](https://developer.android.com/reference/android/app/Dialog#getLayoutInflater())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher) | ` `[getOnBackInvokedDispatcher](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher())`() ` Returns the[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher)instance associated with the window that this dialog is attached to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` final `[Activity](https://developer.android.com/reference/android/app/Activity)                            | ` `[getOwnerActivity](https://developer.android.com/reference/android/app/Dialog#getOwnerActivity())`() ` Returns the Activity that owns this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` final `[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)                     | ` `[getSearchEvent](https://developer.android.com/reference/android/app/Dialog#getSearchEvent())`() ` During the onSearchRequested() callbacks, this function will return the[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)that triggered the callback, if it exists.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` final int`                                                                                                 | ` `[getVolumeControlStream](https://developer.android.com/reference/android/app/Dialog#getVolumeControlStream())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` `[Window](https://developer.android.com/reference/android/view/Window)                                     | ` `[getWindow](https://developer.android.com/reference/android/app/Dialog#getWindow())`() ` Retrieve the current Window for the activity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[hide](https://developer.android.com/reference/android/app/Dialog#hide())`() ` Hide the dialog, but do not dismiss it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[invalidateOptionsMenu](https://developer.android.com/reference/android/app/Dialog#invalidateOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                   | ` `[isShowing](https://developer.android.com/reference/android/app/Dialog#isShowing())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                                      | ` `[onActionModeFinished](https://developer.android.com/reference/android/app/Dialog#onActionModeFinished(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been finished. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeFinished(mode).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` void`                                                                                                      | ` `[onActionModeStarted](https://developer.android.com/reference/android/app/Dialog#onActionModeStarted(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been started. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeStarted(mode).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[onAttachedToWindow](https://developer.android.com/reference/android/app/Dialog#onAttachedToWindow())`() ` Called when the window has been attached to the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` void`                                                                                                      | ` `[onBackPressed](https://developer.android.com/reference/android/app/Dialog#onBackPressed())`() ` *This method was deprecated in API level 33. Use[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)or`androidx.activity.OnBackPressedCallback`to handle back navigation instead.* *Starting from Android 13 (API level 33), back event handling is moving to an ahead-of-time model and[onBackPressed()](https://developer.android.com/reference/android/app/Dialog#onBackPressed())and[KeyEvent.KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)should not be used to handle back events (back gesture or back button click). Instead, an[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)should be registered using[Dialog.getOnBackInvokedDispatcher()](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher())[.registerOnBackInvokedCallback(priority, callback)](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher#registerOnBackInvokedCallback(int,%20android.window.OnBackInvokedCallback)).* |
| ` void`                                                                                                      | ` `[onContentChanged](https://developer.android.com/reference/android/app/Dialog#onContentChanged())`() ` This hook is called whenever the content view of the screen changes (due to a call to[Window.setContentView](https://developer.android.com/reference/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` boolean`                                                                                                   | ` `[onContextItemSelected](https://developer.android.com/reference/android/app/Dialog#onContextItemSelected(android.view.MenuItem))`(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[onContextMenuClosed](https://developer.android.com/reference/android/app/Dialog#onContextMenuClosed(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[onCreateContextMenu](https://developer.android.com/reference/android/app/Dialog#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))`(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu)` menu, `[View](https://developer.android.com/reference/android/view/View)` v, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo)` menuInfo) ` Called when the context menu for this view is being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` boolean`                                                                                                   | ` `[onCreateOptionsMenu](https://developer.android.com/reference/android/app/Dialog#onCreateOptionsMenu(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` It is usually safe to proxy this call to the owner activity's[Activity.onCreateOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onCreateOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                   | ` `[onCreatePanelMenu](https://developer.android.com/reference/android/app/Dialog#onCreatePanelMenu(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Initialize the contents of the menu for panel 'featureId'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` `[View](https://developer.android.com/reference/android/view/View)                                         | ` `[onCreatePanelView](https://developer.android.com/reference/android/app/Dialog#onCreatePanelView(int))`(int featureId) ` Instantiate the view to display in the panel for 'featureId'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[onDetachedFromWindow](https://developer.android.com/reference/android/app/Dialog#onDetachedFromWindow())`() ` Called when the window has been detached from the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                   | ` `[onGenericMotionEvent](https://developer.android.com/reference/android/app/Dialog#onGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when a generic motion event was not handled by any of the views inside of the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` boolean`                                                                                                   | ` `[onKeyDown](https://developer.android.com/reference/android/app/Dialog#onKeyDown(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was pressed down.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` boolean`                                                                                                   | ` `[onKeyLongPress](https://developer.android.com/reference/android/app/Dialog#onKeyLongPress(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Default implementation of[KeyEvent.Callback.onKeyLongPress()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` boolean`                                                                                                   | ` `[onKeyMultiple](https://developer.android.com/reference/android/app/Dialog#onKeyMultiple(int,%20int,%20android.view.KeyEvent))`(int keyCode, int repeatCount, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Default implementation of[KeyEvent.Callback.onKeyMultiple()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                                   | ` `[onKeyShortcut](https://developer.android.com/reference/android/app/Dialog#onKeyShortcut(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key shortcut event is not handled by any of the views in the Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                   | ` `[onKeyUp](https://developer.android.com/reference/android/app/Dialog#onKeyUp(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was released.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` boolean`                                                                                                   | ` `[onMenuItemSelected](https://developer.android.com/reference/android/app/Dialog#onMenuItemSelected(int,%20android.view.MenuItem))`(int featureId, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) ` Called when a panel's menu item has been selected by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                   | ` `[onMenuOpened](https://developer.android.com/reference/android/app/Dialog#onMenuOpened(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel's menu is opened by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` boolean`                                                                                                   | ` `[onOptionsItemSelected](https://developer.android.com/reference/android/app/Dialog#onOptionsItemSelected(android.view.MenuItem))`(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[onOptionsMenuClosed](https://developer.android.com/reference/android/app/Dialog#onOptionsMenuClosed(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[onPanelClosed](https://developer.android.com/reference/android/app/Dialog#onPanelClosed(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel is being closed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                   | ` `[onPrepareOptionsMenu](https://developer.android.com/reference/android/app/Dialog#onPrepareOptionsMenu(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` It is usually safe to proxy this call to the owner activity's[Activity.onPrepareOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onPrepareOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                   | ` `[onPreparePanel](https://developer.android.com/reference/android/app/Dialog#onPreparePanel(int,%20android.view.View,%20android.view.Menu))`(int featureId, `[View](https://developer.android.com/reference/android/view/View)` view, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Prepare a panel to be displayed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                      | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/app/Dialog#onRestoreInstanceState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` savedInstanceState) ` Restore the state of the dialog from a previously saved bundle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[Bundle](https://developer.android.com/reference/android/os/Bundle)                                       | ` `[onSaveInstanceState](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState())`() ` Saves the state of the dialog into a bundle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` boolean`                                                                                                   | ` `[onSearchRequested](https://developer.android.com/reference/android/app/Dialog#onSearchRequested(android.view.SearchEvent))`(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)` searchEvent) ` This hook is called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` boolean`                                                                                                   | ` `[onSearchRequested](https://developer.android.com/reference/android/app/Dialog#onSearchRequested())`() ` This hook is called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                   | ` `[onTouchEvent](https://developer.android.com/reference/android/app/Dialog#onTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when a touch screen event was not handled by any of the views under it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                                   | ` `[onTrackballEvent](https://developer.android.com/reference/android/app/Dialog#onTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when the trackball was moved and not handled by any of the views inside of the activity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[onWindowAttributesChanged](https://developer.android.com/reference/android/app/Dialog#onWindowAttributesChanged(android.view.WindowManager.LayoutParams))`(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams)` params) ` This is called whenever the current window attributes change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                                                      | ` `[onWindowFocusChanged](https://developer.android.com/reference/android/app/Dialog#onWindowFocusChanged(boolean))`(boolean hasFocus) ` This hook is called whenever the window focus changes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode)                             | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/app/Dialog#onWindowStartingActionMode(android.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode)                             | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/app/Dialog#onWindowStartingActionMode(android.view.ActionMode.Callback,%20int))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback, int type) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                                                      | ` `[openContextMenu](https://developer.android.com/reference/android/app/Dialog#openContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                                      | ` `[openOptionsMenu](https://developer.android.com/reference/android/app/Dialog#openOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                                                      | ` `[registerForContextMenu](https://developer.android.com/reference/android/app/Dialog#registerForContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` final boolean`                                                                                             | ` `[requestWindowFeature](https://developer.android.com/reference/android/app/Dialog#requestWindowFeature(int))`(int featureId) ` Enable extended window features.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` final <T extends `[View](https://developer.android.com/reference/android/view/View)`> T`                   | ` `[requireViewById](https://developer.android.com/reference/android/app/Dialog#requireViewById(int))`(int id) ` Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                      | ` `[setCancelMessage](https://developer.android.com/reference/android/app/Dialog#setCancelMessage(android.os.Message))`(`[Message](https://developer.android.com/reference/android/os/Message)` msg) ` Set a message to be sent when the dialog is canceled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                      | ` `[setCancelable](https://developer.android.com/reference/android/app/Dialog#setCancelable(boolean))`(boolean flag) ` Sets whether this dialog is cancelable with the[BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                      | ` `[setCanceledOnTouchOutside](https://developer.android.com/reference/android/app/Dialog#setCanceledOnTouchOutside(boolean))`(boolean cancel) ` Sets whether this dialog is canceled when touched outside the window's bounds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(int))`(int layoutResID) ` Set the screen content from a layout resource.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams)` params) ` Set the screen content to an explicit view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) ` Set the screen content to an explicit view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                                                      | ` `[setDismissMessage](https://developer.android.com/reference/android/app/Dialog#setDismissMessage(android.os.Message))`(`[Message](https://developer.android.com/reference/android/os/Message)` msg) ` Set a message to be sent when the dialog is dismissed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` final void`                                                                                                | ` `[setFeatureDrawable](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawable(int,%20android.graphics.drawable.Drawable))`(int featureId, `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable)` drawable) ` Convenience for calling[Window.setFeatureDrawable(int, Drawable)](https://developer.android.com/reference/android/view/Window#setFeatureDrawable(int,%20android.graphics.drawable.Drawable)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` final void`                                                                                                | ` `[setFeatureDrawableAlpha](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableAlpha(int,%20int))`(int featureId, int alpha) ` Convenience for calling[Window.setFeatureDrawableAlpha(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableAlpha(int,%20int)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` final void`                                                                                                | ` `[setFeatureDrawableResource](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableResource(int,%20int))`(int featureId, int resId) ` Convenience for calling[Window.setFeatureDrawableResource(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableResource(int,%20int)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` final void`                                                                                                | ` `[setFeatureDrawableUri](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableUri(int,%20android.net.Uri))`(int featureId, `[Uri](https://developer.android.com/reference/android/net/Uri)` uri) ` Convenience for calling[Window.setFeatureDrawableUri(int, Uri)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableUri(int,%20android.net.Uri)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[setOnCancelListener](https://developer.android.com/reference/android/app/Dialog#setOnCancelListener(android.content.DialogInterface.OnCancelListener))`(`[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)` listener) ` Set a listener to be invoked when the dialog is canceled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                                      | ` `[setOnDismissListener](https://developer.android.com/reference/android/app/Dialog#setOnDismissListener(android.content.DialogInterface.OnDismissListener))`(`[DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener)` listener) ` Set a listener to be invoked when the dialog is dismissed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                                                      | ` `[setOnKeyListener](https://developer.android.com/reference/android/app/Dialog#setOnKeyListener(android.content.DialogInterface.OnKeyListener))`(`[DialogInterface.OnKeyListener](https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener)` onKeyListener) ` Sets the callback that will be called if a key is dispatched to the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[setOnShowListener](https://developer.android.com/reference/android/app/Dialog#setOnShowListener(android.content.DialogInterface.OnShowListener))`(`[DialogInterface.OnShowListener](https://developer.android.com/reference/android/content/DialogInterface.OnShowListener)` listener) ` Sets a listener to be invoked when the dialog is shown.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` final void`                                                                                                | ` `[setOwnerActivity](https://developer.android.com/reference/android/app/Dialog#setOwnerActivity(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity)` activity) ` Sets the Activity that owns this dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                      | ` `[setTitle](https://developer.android.com/reference/android/app/Dialog#setTitle(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` title) ` Set the title text for this dialog's window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`                                                                                                      | ` `[setTitle](https://developer.android.com/reference/android/app/Dialog#setTitle(int))`(int titleId) ` Set the title text for this dialog's window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` final void`                                                                                                | ` `[setVolumeControlStream](https://developer.android.com/reference/android/app/Dialog#setVolumeControlStream(int))`(int streamType) ` By default, this will use the owner Activity's suggested stream type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                      | ` `[show](https://developer.android.com/reference/android/app/Dialog#show())`() ` Start the dialog and display it on screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                      | ` `[takeKeyEvents](https://developer.android.com/reference/android/app/Dialog#takeKeyEvents(boolean))`(boolean get) ` Request that key events come to this dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`                                                                                                      | ` `[unregisterForContextMenu](https://developer.android.com/reference/android/app/Dialog#unregisterForContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

|                                                                                                                                                                                                                                                     ### Protected methods                                                                                                                                                                                                                                                     ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onCreate](https://developer.android.com/reference/android/app/Dialog#onCreate(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` savedInstanceState) ` Similar to[Activity.onCreate](https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)), you should initialize your dialog in this method, including calling[setContentView(View)](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View)). |
| ` void` | ` `[onStart](https://developer.android.com/reference/android/app/Dialog#onStart())`() ` Called when the dialog is starting.                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void` | ` `[onStop](https://developer.android.com/reference/android/app/Dialog#onStop())`() ` Called to tell you that you're stopping.                                                                                                                                                                                                                                                                                                                                                                                       |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` 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). | ||
| From interface` `[android.view.KeyEvent.Callback](https://developer.android.com/reference/android/view/KeyEvent.Callback)` ` |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` `[onKeyDown](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyDown(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key down event has occurred.                                                                                                                                                               | | ` abstract boolean` | ` `[onKeyLongPress](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a long press has occurred.                                                                                                                                                         | | ` abstract boolean` | ` `[onKeyMultiple](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent))`(int keyCode, int count, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession. | | ` abstract boolean` | ` `[onKeyUp](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyUp(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key up event has occurred.                                                                                                                                                                     | ||
| From interface` `[android.view.View.OnCreateContextMenuListener](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[onCreateContextMenu](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))`(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu)` menu, `[View](https://developer.android.com/reference/android/view/View)` v, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo)` menuInfo) ` Called when the context menu for this view is being built. | ||
| From interface` `[android.view.Window.Callback](https://developer.android.com/reference/android/view/Window.Callback)` ` |-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                       | ` `[dispatchGenericMotionEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process generic motion events.                                                                                                                                                                                                                                                                | | ` abstract boolean`                                                                       | ` `[dispatchKeyEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchKeyEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process key events.                                                                                                                                                                                                                                                                                                        | | ` abstract boolean`                                                                       | ` `[dispatchKeyShortcutEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchKeyShortcutEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process a key shortcut event.                                                                                                                                                                                                                                                                              | | ` abstract boolean`                                                                       | ` `[dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent))`(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)` event) ` Called to process population of[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)s.                                                                                           | | ` abstract boolean`                                                                       | ` `[dispatchTouchEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process touch screen events.                                                                                                                                                                                                                                                                                  | | ` abstract boolean`                                                                       | ` `[dispatchTrackballEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process trackball events.                                                                                                                                                                                                                                                                             | | ` abstract void`                                                                          | ` `[onActionModeFinished](https://developer.android.com/reference/android/view/Window.Callback#onActionModeFinished(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been finished.                                                                                                                                                                                                                                                                           | | ` abstract void`                                                                          | ` `[onActionModeStarted](https://developer.android.com/reference/android/view/Window.Callback#onActionModeStarted(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been started.                                                                                                                                                                                                                                                                              | | ` abstract void`                                                                          | ` `[onAttachedToWindow](https://developer.android.com/reference/android/view/Window.Callback#onAttachedToWindow())`() ` Called when the window has been attached to the window manager.                                                                                                                                                                                                                                                                                                                                                                        | | ` abstract void`                                                                          | ` `[onContentChanged](https://developer.android.com/reference/android/view/Window.Callback#onContentChanged())`() ` This hook is called whenever the content view of the screen changes (due to a call to[Window.setContentView](https://developer.android.com/reference/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).                        | | ` abstract boolean`                                                                       | ` `[onCreatePanelMenu](https://developer.android.com/reference/android/view/Window.Callback#onCreatePanelMenu(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Initialize the contents of the menu for panel 'featureId'.                                                                                                                                                                                                                                                                | | ` abstract `[View](https://developer.android.com/reference/android/view/View)             | ` `[onCreatePanelView](https://developer.android.com/reference/android/view/Window.Callback#onCreatePanelView(int))`(int featureId) ` Instantiate the view to display in the panel for 'featureId'.                                                                                                                                                                                                                                                                                                                                                            | | ` abstract void`                                                                          | ` `[onDetachedFromWindow](https://developer.android.com/reference/android/view/Window.Callback#onDetachedFromWindow())`() ` Called when the window has been detached from the window manager.                                                                                                                                                                                                                                                                                                                                                                  | | ` abstract boolean`                                                                       | ` `[onMenuItemSelected](https://developer.android.com/reference/android/view/Window.Callback#onMenuItemSelected(int,%20android.view.MenuItem))`(int featureId, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) ` Called when a panel's menu item has been selected by the user.                                                                                                                                                                                                                                              | | ` abstract boolean`                                                                       | ` `[onMenuOpened](https://developer.android.com/reference/android/view/Window.Callback#onMenuOpened(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel's menu is opened by the user.                                                                                                                                                                                                                                                                                   | | ` abstract void`                                                                          | ` `[onPanelClosed](https://developer.android.com/reference/android/view/Window.Callback#onPanelClosed(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel is being closed.                                                                                                                                                                                                                                                                                              | | ` default void`                                                                           | ` `[onPointerCaptureChanged](https://developer.android.com/reference/android/view/Window.Callback#onPointerCaptureChanged(boolean))`(boolean hasCapture) ` Called when pointer capture is enabled or disabled for the current window.                                                                                                                                                                                                                                                                                                                          | | ` abstract boolean`                                                                       | ` `[onPreparePanel](https://developer.android.com/reference/android/view/Window.Callback#onPreparePanel(int,%20android.view.View,%20android.view.Menu))`(int featureId, `[View](https://developer.android.com/reference/android/view/View)` view, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Prepare a panel to be displayed.                                                                                                                                                                                                 | | ` default void`                                                                           | ` `[onProvideKeyboardShortcuts](https://developer.android.com/reference/android/view/Window.Callback#onProvideKeyboardShortcuts(java.util.List<android.view.KeyboardShortcutGroup>,%20android.view.Menu,%20int))`(`[List](https://developer.android.com/reference/java/util/List)`<`[KeyboardShortcutGroup](https://developer.android.com/reference/android/view/KeyboardShortcutGroup)`> data, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu, int deviceId) ` Called when Keyboard Shortcuts are requested for the current window. | | ` abstract boolean`                                                                       | ` `[onSearchRequested](https://developer.android.com/reference/android/view/Window.Callback#onSearchRequested())`() ` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                               | | ` abstract boolean`                                                                       | ` `[onSearchRequested](https://developer.android.com/reference/android/view/Window.Callback#onSearchRequested(android.view.SearchEvent))`(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)` searchEvent) ` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                          | | ` abstract void`                                                                          | ` `[onWindowAttributesChanged](https://developer.android.com/reference/android/view/Window.Callback#onWindowAttributesChanged(android.view.WindowManager.LayoutParams))`(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams)` attrs) ` This is called whenever the current window attributes change.                                                                                                                                                                                                | | ` abstract void`                                                                          | ` `[onWindowFocusChanged](https://developer.android.com/reference/android/view/Window.Callback#onWindowFocusChanged(boolean))`(boolean hasFocus) ` This hook is called whenever the window focus changes.                                                                                                                                                                                                                                                                                                                                                      | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode) | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                 | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode) | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback,%20int))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback, int type) ` Called when an action mode is being started for this window.                                                                                                                                                                                                | ||

## Public constructors

### Dialog

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

```
public Dialog (Context context)
```

Creates a dialog window that uses the default dialog theme.

The supplied`context`is used to obtain the window manager and base theme used to present the dialog.

<br />

|                                             Parameters                                              ||
|-----------|------------------------------------------------------------------------------------------|
| `context` | `Context`: the context in which the dialog should run This value cannot be`null`. <br /> |

**See also:**

- [R.styleable.Theme_dialogTheme](https://developer.android.com/reference/android/R.styleable#Theme_dialogTheme)  

### Dialog

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

```
public Dialog (Context context, 
                int themeResId)
```

Creates a dialog window that uses a custom dialog style.

The supplied`context`is used to obtain the window manager and base theme used to present the dialog.

The supplied`theme`is applied on top of the context's theme. See[Style and Theme Resources](https://developer.android.com/guide/topics/resources/available-resources#stylesandthemes)for more information about defining and using styles.

<br />

|                                                          Parameters                                                           ||
|--------------|-----------------------------------------------------------------------------------------------------------------|
| `context`    | `Context`: the context in which the dialog should run This value cannot be`null`. <br />                        |
| `themeResId` | `int`: a style resource describing the theme to use for the window, or`0`to use the default dialog theme <br /> |

## Protected constructors

### Dialog

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

```
protected Dialog (Context context, 
                boolean cancelable, 
                DialogInterface.OnCancelListener cancelListener)
```

<br />

<br />

|                                      Parameters                                       ||
|------------------|---------------------------------------------------------------------|
| `context`        | `Context`: This value cannot be`null`. <br />                       |
| `cancelable`     | `boolean` <br />                                                    |
| `cancelListener` | `DialogInterface.OnCancelListener`: This value may be`null`. <br /> |

## Public methods

### addContentView

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

```
public void addContentView (View view, 
                ViewGroup.LayoutParams params)
```

Add an additional content view to the screen. Added after any existing ones in the screen -- existing views are NOT removed.

<br />

|                                             Parameters                                              ||
|----------|-------------------------------------------------------------------------------------------|
| `view`   | `View`: The desired content to display. This value cannot be`null`. <br />                |
| `params` | `ViewGroup.LayoutParams`: Layout parameters for the view. This value may be`null`. <br /> |

### cancel

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

```
public void cancel ()
```

Cancel the dialog. This is essentially the same as calling[dismiss()](https://developer.android.com/reference/android/app/Dialog#dismiss()), but it will also call your[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)(if registered).

<br />

### closeOptionsMenu

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

```
public void closeOptionsMenu ()
```

<br />

<br />

**See also:**

- [Activity.closeOptionsMenu()](https://developer.android.com/reference/android/app/Activity#closeOptionsMenu())  

### create

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

```
public void create ()
```

Forces immediate creation of the dialog.

Note that you should not override this method to perform dialog creation. Rather, override[onCreate(android.os.Bundle)](https://developer.android.com/reference/android/app/Dialog#onCreate(android.os.Bundle)).

<br />

### dismiss

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

```
public void dismiss ()
```

Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when the dialog is dismissed, instead implement that in[onStop()](https://developer.android.com/reference/android/app/Dialog#onStop()).

<br />

### dispatchGenericMotionEvent

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

```
public boolean dispatchGenericMotionEvent (MotionEvent ev)
```

Called to process generic motion events. You can override this to intercept all generic motion events before they are dispatched to the window. Be sure to call this implementation for generic motion events that should be handled normally.

<br />

|                                    Parameters                                     ||
|------|-----------------------------------------------------------------------------|
| `ev` | `MotionEvent`: The generic motion event. This value cannot be`null`. <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | boolean Return true if this event was consumed. <br /> |

### dispatchKeyEvent

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

```
public boolean dispatchKeyEvent (KeyEvent event)
```

Called to process key events. You can override this to intercept all key events before they are dispatched to the window. Be sure to call this implementation for key events that should be handled normally.

<br />

|                               Parameters                               ||
|---------|---------------------------------------------------------------|
| `event` | `KeyEvent`: The key event. This value cannot be`null`. <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | boolean Return true if this event was consumed. <br /> |

### dispatchKeyShortcutEvent

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

```
public boolean dispatchKeyShortcutEvent (KeyEvent event)
```

Called to process a key shortcut event. You can override this to intercept all key shortcut events before they are dispatched to the window. Be sure to call this implementation for key shortcut events that should be handled normally.

<br />

|                                   Parameters                                    ||
|---------|------------------------------------------------------------------------|
| `event` | `KeyEvent`: The key shortcut event. This value cannot be`null`. <br /> |

|                      Returns                       ||
|-----------|-----------------------------------------|
| `boolean` | True if this event was consumed. <br /> |

### dispatchPopulateAccessibilityEvent

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

```
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
```

Called to process population of[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)s.

<br />

|                            Parameters                             ||
|---------|----------------------------------------------------------|
| `event` | `AccessibilityEvent`: This value cannot be`null`. <br /> |

|                                 Returns                                  ||
|-----------|---------------------------------------------------------------|
| `boolean` | boolean Return true if event population was completed. <br /> |

### dispatchTouchEvent

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

```
public boolean dispatchTouchEvent (MotionEvent ev)
```

Called to process touch screen events. You can override this to intercept all touch screen events before they are dispatched to the window. Be sure to call this implementation for touch screen events that should be handled normally.

<br />

|                                   Parameters                                    ||
|------|---------------------------------------------------------------------------|
| `ev` | `MotionEvent`: The touch screen event. This value cannot be`null`. <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | boolean Return true if this event was consumed. <br /> |

### dispatchTrackballEvent

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

```
public boolean dispatchTrackballEvent (MotionEvent ev)
```

Called to process trackball events. You can override this to intercept all trackball events before they are dispatched to the window. Be sure to call this implementation for trackball events that should be handled normally.

<br />

|                                  Parameters                                  ||
|------|------------------------------------------------------------------------|
| `ev` | `MotionEvent`: The trackball event. This value cannot be`null`. <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | boolean Return true if this event was consumed. <br /> |

### findViewById

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

```
public T findViewById (int id)
```

Finds the first descendant view with the given ID or`null`if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).

**Note:**In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

<br />

|                Parameters                ||
|------|------------------------------------|
| `id` | `int`: the ID to search for <br /> |

|                           Returns                            ||
|-----|---------------------------------------------------------|
| `T` | a view with given ID if found, or`null`otherwise <br /> |

**See also:**

- [View.findViewById(int)](https://developer.android.com/reference/android/view/View#findViewById(int))
- [requireViewById(int)](https://developer.android.com/reference/android/app/Dialog#requireViewById(int))  

### getActionBar

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

```
public ActionBar getActionBar ()
```

Retrieve the[ActionBar](https://developer.android.com/reference/android/app/ActionBar)attached to this dialog, if present.

<br />

|                                                                           Returns                                                                           ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [ActionBar](https://developer.android.com/reference/android/app/ActionBar) | The ActionBar attached to the dialog or null if no ActionBar is present. <br /> |

### getContext

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

```
public final Context getContext ()
```

Retrieve the Context this Dialog is running in.

<br />

|                                                                        Returns                                                                         ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [Context](https://developer.android.com/reference/android/content/Context) | Context The Context used by the Dialog. This value cannot be`null`. <br /> |

### getCurrentFocus

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

```
public View getCurrentFocus ()
```

Call[Window.getCurrentFocus()](https://developer.android.com/reference/android/view/Window#getCurrentFocus())on the Window if this Activity to return the currently focused view.

<br />

|                                                       Returns                                                       ||
|-------------------------------------------------------------------|--------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View) | View The current View with focus or null. <br /> |

**See also:**

- [getWindow()](https://developer.android.com/reference/android/app/Dialog#getWindow())
- [Window.getCurrentFocus()](https://developer.android.com/reference/android/view/Window#getCurrentFocus())  

### getLayoutInflater

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

```
public LayoutInflater getLayoutInflater ()
```

<br />

<br />

|                                                          Returns                                                          ||
|---------------------------------------------------------------------------------------|------------------------------------|
| [LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater) | This value cannot be`null`. <br /> |

### getOnBackInvokedDispatcher

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

```
public OnBackInvokedDispatcher getOnBackInvokedDispatcher ()
```

Returns the[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher)instance associated with the window that this dialog is attached to.

<br />

|                                                                    Returns                                                                    ||
|-----------------------------------------------------------------------------------------------------------|------------------------------------|
| [OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher) | This value cannot be`null`. <br /> |

### getOwnerActivity

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

```
public final Activity getOwnerActivity ()
```

Returns the Activity that owns this Dialog. For example, if[Activity.showDialog(int)](https://developer.android.com/reference/android/app/Activity#showDialog(int))is used to show this Dialog, that Activity will be the owner (by default). Depending on how this dialog was created, this may return null.

<br />

|                                                       Returns                                                        ||
|--------------------------------------------------------------------------|--------------------------------------------|
| [Activity](https://developer.android.com/reference/android/app/Activity) | The Activity that owns this Dialog. <br /> |

### getSearchEvent

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

```
public final SearchEvent getSearchEvent ()
```

During the onSearchRequested() callbacks, this function will return the[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)that triggered the callback, if it exists.

<br />

|                                                                                                                                    Returns                                                                                                                                    ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SearchEvent](https://developer.android.com/reference/android/view/SearchEvent) | SearchEvent The SearchEvent that triggered the[onSearchRequested()](https://developer.android.com/reference/android/app/Dialog#onSearchRequested())callback. This value may be`null`. <br /> |

### getVolumeControlStream

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

```
public final int getVolumeControlStream ()
```

<br />

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [Activity.getVolumeControlStream()](https://developer.android.com/reference/android/app/Activity#getVolumeControlStream())  

### getWindow

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

```
public Window getWindow ()
```

Retrieve the current Window for the activity. This can be used to directly access parts of the Window API that are not available through Activity/Screen.

<br />

|                                                                     Returns                                                                     ||
|-----------------------------------------------------------------------|--------------------------------------------------------------------------|
| [Window](https://developer.android.com/reference/android/view/Window) | Window The current window, or null if the activity is not visual. <br /> |

### hide

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

```
public void hide ()
```

Hide the dialog, but do not dismiss it.

<br />

### invalidateOptionsMenu

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

```
public void invalidateOptionsMenu ()
```

<br />

<br />

**See also:**

- [Activity.invalidateOptionsMenu()](https://developer.android.com/reference/android/app/Activity#invalidateOptionsMenu())  

### isShowing

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

```
public boolean isShowing ()
```

<br />

<br />

|                          Returns                           ||
|-----------|-------------------------------------------------|
| `boolean` | Whether the dialog is currently showing. <br /> |

### onActionModeFinished

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

```
public void onActionModeFinished (ActionMode mode)
```

Called when an action mode has been finished. The appropriate mode callback method will have already been invoked. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeFinished(mode).  
If you override this method you*must*call through to the superclass implementation.

<br />

|                          Parameters                           ||
|--------|-------------------------------------------------------|
| `mode` | `ActionMode`: The mode that was just finished. <br /> |

### onActionModeStarted

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

```
public void onActionModeStarted (ActionMode mode)
```

Called when an action mode has been started. The appropriate mode callback method will have already been invoked. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeStarted(mode).  
If you override this method you*must*call through to the superclass implementation.

<br />

|                              Parameters                               ||
|--------|---------------------------------------------------------------|
| `mode` | `ActionMode`: The new mode that has just been started. <br /> |

### onAttachedToWindow

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

```
public void onAttachedToWindow ()
```

Called when the window has been attached to the window manager. See[View.onAttachedToWindow()](https://developer.android.com/reference/android/view/View#onAttachedToWindow())for more information.

<br />

### onBackPressed

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

```
public void onBackPressed ()
```

<br />

**This method was deprecated in API level 33.**   
Use[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)or`androidx.activity.OnBackPressedCallback`to handle back navigation instead.

Starting from Android 13 (API level 33), back event handling is moving to an ahead-of-time model and[onBackPressed()](https://developer.android.com/reference/android/app/Dialog#onBackPressed())and[KeyEvent.KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)should not be used to handle back events (back gesture or back button click). Instead, an[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)should be registered using[Dialog.getOnBackInvokedDispatcher()](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher())[.registerOnBackInvokedCallback(priority, callback)](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher#registerOnBackInvokedCallback(int,%20android.window.OnBackInvokedCallback)).

Called when the dialog has detected the user's press of the back key. The default implementation simply cancels the dialog (only if it is cancelable), but you can override this to do whatever you want.

If you target version[Build.VERSION_CODES.TIRAMISU](https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU)or later, you should not use this method but register an[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)on an[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher)that you can retrieve using[getOnBackInvokedDispatcher()](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher()). You should also set`android:enableOnBackInvokedCallback="true"`in the application manifest.

Alternatively, you can use`androidx.activity.ComponentDialog#getOnBackPressedDispatcher()`for backward compatibility.

<br />

### onContentChanged

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

```
public void onContentChanged ()
```

This hook is called whenever the content view of the screen changes (due to a call to[Window.setContentView](https://developer.android.com/reference/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).

<br />

### onContextItemSelected

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

```
public boolean onContextItemSelected (MenuItem item)
```

<br />

<br />

|                       Parameters                       ||
|--------|------------------------------------------------|
| `item` | `MenuItem`: This value cannot be`null`. <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

**See also:**

- [Activity.onContextItemSelected(MenuItem)](https://developer.android.com/reference/android/app/Activity#onContextItemSelected(android.view.MenuItem))  

### onContextMenuClosed

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

```
public void onContextMenuClosed (Menu menu)
```

<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `menu` | `Menu`: This value cannot be`null`. <br /> |

**See also:**

- [Activity.onContextMenuClosed(Menu)](https://developer.android.com/reference/android/app/Activity#onContextMenuClosed(android.view.Menu))  

### onCreateContextMenu

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

```
public void onCreateContextMenu (ContextMenu menu, 
                View v, 
                ContextMenu.ContextMenuInfo menuInfo)
```

Called when the context menu for this view is being built. It is not safe to hold onto the menu after this method returns.

<br />

|                                                                                       Parameters                                                                                       ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `menu`     | `ContextMenu`: The context menu that is being built <br />                                                                                                                 |
| `v`        | `View`: The view for which the context menu is being built <br />                                                                                                          |
| `menuInfo` | `ContextMenu.ContextMenuInfo`: Extra information about the item for which the context menu should be shown. This information will vary depending on the class of v. <br /> |

**See also:**

- [Activity.onCreateContextMenu(ContextMenu, View, ContextMenuInfo)](https://developer.android.com/reference/android/app/Activity#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))  

### onCreateOptionsMenu

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

```
public boolean onCreateOptionsMenu (Menu menu)
```

It is usually safe to proxy this call to the owner activity's[Activity.onCreateOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onCreateOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `menu` | `Menu`: This value cannot be`null`. <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

**See also:**

- [Activity.onCreateOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onCreateOptionsMenu(android.view.Menu))
- [getOwnerActivity()](https://developer.android.com/reference/android/app/Dialog#getOwnerActivity())  

### onCreatePanelMenu

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

```
public boolean onCreatePanelMenu (int featureId, 
                Menu menu)
```

Initialize the contents of the menu for panel 'featureId'. This is called if onCreatePanelView() returns null, giving you a standard menu in which you can place your items. It is only called once for the panel, the first time it is shown.

You can safely hold on to<var translate="no">menu</var>(and any items created from it), making modifications to it as desired, until the next time onCreatePanelMenu() is called for this feature.

<br />

|                       Parameters                        ||
|-------------|--------------------------------------------|
| `featureId` | `int`: The panel being created. <br />     |
| `menu`      | `Menu`: This value cannot be`null`. <br /> |

|                                                         Returns                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `boolean` | boolean You must return true for the panel to be displayed; if you return false it will not be shown. <br /> |

**See also:**

- [Activity.onCreatePanelMenu(int, Menu)](https://developer.android.com/reference/android/app/Activity#onCreatePanelMenu(int,%20android.view.Menu))  

### onCreatePanelView

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

```
public View onCreatePanelView (int featureId)
```

Instantiate the view to display in the panel for 'featureId'. You can return null, in which case the default content (typically a menu) will be created for you.

<br />

|                        Parameters                        ||
|-------------|---------------------------------------------|
| `featureId` | `int`: Which panel is being created. <br /> |

|                                                         Returns                                                          ||
|-------------------------------------------------------------------|-------------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View) | view The top-level view to place in the panel. <br /> |

**See also:**

- [Activity.onCreatePanelView(int)](https://developer.android.com/reference/android/app/Activity#onCreatePanelView(int))  

### onDetachedFromWindow

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

```
public void onDetachedFromWindow ()
```

Called when the window has been detached from the window manager. See[View.onDetachedFromWindow()](https://developer.android.com/reference/android/view/View#onDetachedFromWindow())for more information.

<br />

### onGenericMotionEvent

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

```
public boolean onGenericMotionEvent (MotionEvent event)
```

Called when a generic motion event was not handled by any of the views inside of the dialog.

Generic motion events describe joystick movements, mouse hovers, track pad touches, scroll wheel movements and other input events. The[source](https://developer.android.com/reference/android/view/MotionEvent#getSource())of the motion event specifies the class of input that was received. Implementations of this method must examine the bits in the source before processing the event. The following code example shows how this is done.

Generic motion events with source class[InputDevice.SOURCE_CLASS_POINTER](https://developer.android.com/reference/android/view/InputDevice#SOURCE_CLASS_POINTER)are delivered to the view under the pointer. All other generic motion events are delivered to the focused view.

See[View.onGenericMotionEvent(MotionEvent)](https://developer.android.com/reference/android/view/View#onGenericMotionEvent(android.view.MotionEvent))for an example of how to handle this event.

<br />

<br />

|                                              Parameters                                              ||
|---------|---------------------------------------------------------------------------------------------|
| `event` | `MotionEvent`: The generic motion event being processed. This value cannot be`null`. <br /> |

|                                                               Returns                                                                ||
|-----------|---------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Return true if you have consumed the event, false if you haven't. The default implementation always returns false. <br /> |

### onKeyDown

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

```
public boolean onKeyDown (int keyCode, 
                KeyEvent event)
```

A key was pressed down.

If the focused view didn't want this event, this method is called.

Default implementation consumes[KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)and, as of[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES#P),[KEYCODE_ESCAPE](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ESCAPE)to later handle them in[onKeyUp(int, KeyEvent)](https://developer.android.com/reference/android/app/Dialog#onKeyUp(int,%20android.view.KeyEvent)).

<br />

|                        Parameters                         ||
|-----------|------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event`   | `KeyEvent`: This value cannot be`null`. <br /> |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

**See also:**

- [onKeyUp(int, KeyEvent)](https://developer.android.com/reference/android/app/Dialog#onKeyUp(int,%20android.view.KeyEvent))
- [KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)  

### onKeyLongPress

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

```
public boolean onKeyLongPress (int keyCode, 
                KeyEvent event)
```

Default implementation of[KeyEvent.Callback.onKeyLongPress()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

<br />

|                        Parameters                         ||
|-----------|------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event`   | `KeyEvent`: This value cannot be`null`. <br /> |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

### onKeyMultiple

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

```
public boolean onKeyMultiple (int keyCode, 
                int repeatCount, 
                KeyEvent event)
```

Default implementation of[KeyEvent.Callback.onKeyMultiple()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

<br />

|                                     Parameters                                      ||
|---------------|----------------------------------------------------------------------|
| `keyCode`     | `int`: The value in event.getKeyCode(). <br />                       |
| `repeatCount` | `int`: Number of pairs as returned by event.getRepeatCount(). <br /> |
| `event`       | `KeyEvent`: This value cannot be`null`. <br />                       |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

### onKeyShortcut

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

```
public boolean onKeyShortcut (int keyCode, 
                KeyEvent event)
```

Called when a key shortcut event is not handled by any of the views in the Dialog. Override this method to implement global key shortcuts for the Dialog. Key shortcuts can also be implemented by setting the[shortcut](https://developer.android.com/reference/android/view/MenuItem#setShortcut(char,%20char))property of menu items.

<br />

|                                       Parameters                                        ||
|-----------|------------------------------------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br />                               |
| `event`   | `KeyEvent`: Description of the key event. This value cannot be`null`. <br /> |

|                         Returns                         ||
|-----------|----------------------------------------------|
| `boolean` | True if the key shortcut was handled. <br /> |

### onKeyUp

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

```
public boolean onKeyUp (int keyCode, 
                KeyEvent event)
```

A key was released.

Default implementation consumes[KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)and, as of[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES#P),[KEYCODE_ESCAPE](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ESCAPE)to close the dialog.

<br />

|                        Parameters                         ||
|-----------|------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event`   | `KeyEvent`: This value cannot be`null`. <br /> |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

**See also:**

- [onKeyDown(int, KeyEvent)](https://developer.android.com/reference/android/app/Dialog#onKeyDown(int,%20android.view.KeyEvent))
- [KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)  

### onMenuItemSelected

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

```
public boolean onMenuItemSelected (int featureId, 
                MenuItem item)
```

Called when a panel's menu item has been selected by the user.

<br />

|                         Parameters                          ||
|-------------|------------------------------------------------|
| `featureId` | `int`: The panel that the menu is in. <br />   |
| `item`      | `MenuItem`: This value cannot be`null`. <br /> |

|                                                                                         Returns                                                                                          ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | boolean Return true to finish processing of selection, or false to perform the normal menu handling (calling its Runnable or sending a Message to its target Handler). <br /> |

**See also:**

- [Activity.onMenuItemSelected(int, MenuItem)](https://developer.android.com/reference/android/app/Activity#onMenuItemSelected(int,%20android.view.MenuItem))  

### onMenuOpened

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

```
public boolean onMenuOpened (int featureId, 
                Menu menu)
```

Called when a panel's menu is opened by the user. This may also be called when the menu is changing from one type to another (for example, from the icon menu to the expanded menu).

<br />

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `featureId` | `int`: The panel that the menu is in. <br /> |
| `menu`      | `Menu`: This value cannot be`null`. <br />   |

|                                               Returns                                               ||
|-----------|------------------------------------------------------------------------------------------|
| `boolean` | Return true to allow the menu to open, or false to prevent the menu from opening. <br /> |

**See also:**

- [Activity.onMenuOpened(int, Menu)](https://developer.android.com/reference/android/app/Activity#onMenuOpened(int,%20android.view.Menu))  

### onOptionsItemSelected

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

```
public boolean onOptionsItemSelected (MenuItem item)
```

<br />

<br />

|                       Parameters                       ||
|--------|------------------------------------------------|
| `item` | `MenuItem`: This value cannot be`null`. <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

**See also:**

- [Activity.onOptionsItemSelected(MenuItem)](https://developer.android.com/reference/android/app/Activity#onOptionsItemSelected(android.view.MenuItem))  

### onOptionsMenuClosed

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

```
public void onOptionsMenuClosed (Menu menu)
```

<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `menu` | `Menu`: This value cannot be`null`. <br /> |

**See also:**

- [Activity.onOptionsMenuClosed(Menu)](https://developer.android.com/reference/android/app/Activity#onOptionsMenuClosed(android.view.Menu))  

### onPanelClosed

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

```
public void onPanelClosed (int featureId, 
                Menu menu)
```

Called when a panel is being closed. If another logical subsequent panel is being opened (and this panel is being closed to make room for the subsequent panel), this method will NOT be called.

<br />

|                          Parameters                           ||
|-------------|--------------------------------------------------|
| `featureId` | `int`: The panel that is being displayed. <br /> |
| `menu`      | `Menu`: This value cannot be`null`. <br />       |

**See also:**

- [Activity.onPanelClosed(int, Menu)](https://developer.android.com/reference/android/app/Activity#onPanelClosed(int,%20android.view.Menu))  

### onPrepareOptionsMenu

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

```
public boolean onPrepareOptionsMenu (Menu menu)
```

It is usually safe to proxy this call to the owner activity's[Activity.onPrepareOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onPrepareOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `menu` | `Menu`: This value cannot be`null`. <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

**See also:**

- [Activity.onPrepareOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onPrepareOptionsMenu(android.view.Menu))
- [getOwnerActivity()](https://developer.android.com/reference/android/app/Dialog#getOwnerActivity())  

### onPreparePanel

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

```
public boolean onPreparePanel (int featureId, 
                View view, 
                Menu menu)
```

Prepare a panel to be displayed. This is called right before the panel window is shown, every time it is shown.

<br />

|                          Parameters                           ||
|-------------|--------------------------------------------------|
| `featureId` | `int`: The panel that is being displayed. <br /> |
| `view`      | `View`: This value may be`null`. <br />          |
| `menu`      | `Menu`: This value cannot be`null`. <br />       |

|                                                         Returns                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `boolean` | boolean You must return true for the panel to be displayed; if you return false it will not be shown. <br /> |

**See also:**

- [Activity.onPreparePanel(int, View, Menu)](https://developer.android.com/reference/android/app/Activity#onPreparePanel(int,%20android.view.View,%20android.view.Menu))  

### onRestoreInstanceState

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

```
public void onRestoreInstanceState (Bundle savedInstanceState)
```

Restore the state of the dialog from a previously saved bundle. The default implementation restores the state of the dialog's view hierarchy that was saved in the default implementation of[onSaveInstanceState()](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState()), so be sure to call through to super when overriding unless you want to do all restoring of state yourself.

<br />

|                                                                                                        Parameters                                                                                                        ||
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `savedInstanceState` | `Bundle`: The state of the dialog previously saved by[onSaveInstanceState()](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState()). This value cannot be`null`. <br /> |

### onSaveInstanceState

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

```
public Bundle onSaveInstanceState ()
```

Saves the state of the dialog into a bundle. The default implementation saves the state of its view hierarchy, so you'll likely want to call through to super if you override this to save additional state.

<br />

|                                                                    Returns                                                                     ||
|---------------------------------------------------------------------|---------------------------------------------------------------------------|
| [Bundle](https://developer.android.com/reference/android/os/Bundle) | A bundle with the state of the dialog. This value cannot be`null`. <br /> |

### onSearchRequested

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

```
public boolean onSearchRequested (SearchEvent searchEvent)
```

This hook is called when the user signals the desire to start a search.

<br />

|                            Parameters                            ||
|---------------|---------------------------------------------------|
| `searchEvent` | `SearchEvent`: This value cannot be`null`. <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | true if search launched, false if activity refuses (blocks) <br /> |

### onSearchRequested

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

```
public boolean onSearchRequested ()
```

This hook is called when the user signals the desire to start a search.

<br />

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | true if search launched, false if activity refuses (blocks) <br /> |

### onTouchEvent

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

```
public boolean onTouchEvent (MotionEvent event)
```

Called when a touch screen event was not handled by any of the views under it. This is most useful to process touch events that happen outside of your window bounds, where there is no view to receive it.

<br />

|                                             Parameters                                             ||
|---------|-------------------------------------------------------------------------------------------|
| `event` | `MotionEvent`: The touch screen event being processed. This value cannot be`null`. <br /> |

|                                                                                         Returns                                                                                          ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Return true if you have consumed the event, false if you haven't. The default implementation will cancel the dialog when a touch happens outside of the window bounds. <br /> |

### onTrackballEvent

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

```
public boolean onTrackballEvent (MotionEvent event)
```

Called when the trackball was moved and not handled by any of the views inside of the activity. So, for example, if the trackball moves while focus is on a button, you will receive a call here because buttons do not normally do anything with trackball events. The call here happens*before*trackball movements are converted to DPAD key events, which then get sent back to the view hierarchy, and will be processed at the point for things like focus navigation.

<br />

|                                           Parameters                                            ||
|---------|----------------------------------------------------------------------------------------|
| `event` | `MotionEvent`: The trackball event being processed. This value cannot be`null`. <br /> |

|                                                               Returns                                                                ||
|-----------|---------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Return true if you have consumed the event, false if you haven't. The default implementation always returns false. <br /> |

### onWindowAttributesChanged

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

```
public void onWindowAttributesChanged (WindowManager.LayoutParams params)
```

This is called whenever the current window attributes change.

<br />

|                  Parameters                   ||
|----------|-------------------------------------|
| `params` | `WindowManager.LayoutParams` <br /> |

### onWindowFocusChanged

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

```
public void onWindowFocusChanged (boolean hasFocus)
```

This hook is called whenever the window focus changes. See[View.onWindowFocusChangedNotLocked(boolean)](https://developer.android.com/reference/android/view/View#onWindowFocusChanged(boolean))for more information.

<br />

|                           Parameters                            ||
|------------|-----------------------------------------------------|
| `hasFocus` | `boolean`: Whether the window now has focus. <br /> |

### onWindowStartingActionMode

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

```
public ActionMode onWindowStartingActionMode (ActionMode.Callback callback)
```

Called when an action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all. This is equivalent to[onWindowStartingActionMode(android.view.ActionMode.Callback, int)](https://developer.android.com/reference/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback,%20int))with type[ActionMode.TYPE_PRIMARY](https://developer.android.com/reference/android/view/ActionMode#TYPE_PRIMARY).

<br />

|                                           Parameters                                            ||
|------------|-------------------------------------------------------------------------------------|
| `callback` | `ActionMode.Callback`: Callback to control the lifecycle of this action mode <br /> |

|                                                                            Returns                                                                             ||
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [ActionMode](https://developer.android.com/reference/android/view/ActionMode) | The ActionMode that was started, or null if the system should present it <br /> |

### onWindowStartingActionMode

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

```
public ActionMode onWindowStartingActionMode (ActionMode.Callback callback, 
                int type)
```

Called when an action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all.

<br />

|                                                                                                                     Parameters                                                                                                                      ||
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callback` | `ActionMode.Callback`: Callback to control the lifecycle of this action mode <br />                                                                                                                                                     |
| `type`     | `int`: One of[ActionMode.TYPE_PRIMARY](https://developer.android.com/reference/android/view/ActionMode#TYPE_PRIMARY)or[ActionMode.TYPE_FLOATING](https://developer.android.com/reference/android/view/ActionMode#TYPE_FLOATING). <br /> |

|                                                                            Returns                                                                             ||
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [ActionMode](https://developer.android.com/reference/android/view/ActionMode) | The ActionMode that was started, or null if the system should present it <br /> |

### openContextMenu

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

```
public void openContextMenu (View view)
```

<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `view` | `View`: This value cannot be`null`. <br /> |

**See also:**

- [Activity.openContextMenu(View)](https://developer.android.com/reference/android/app/Activity#openContextMenu(android.view.View))  

### openOptionsMenu

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

```
public void openOptionsMenu ()
```

<br />

<br />

**See also:**

- [Activity.openOptionsMenu()](https://developer.android.com/reference/android/app/Activity#openOptionsMenu())  

### registerForContextMenu

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

```
public void registerForContextMenu (View view)
```

<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `view` | `View`: This value cannot be`null`. <br /> |

**See also:**

- [Activity.registerForContextMenu(View)](https://developer.android.com/reference/android/app/Activity#registerForContextMenu(android.view.View))  

### requestWindowFeature

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

```
public final boolean requestWindowFeature (int featureId)
```

Enable extended window features. This is a convenience for calling[getWindow().requestFeature()](https://developer.android.com/reference/android/view/Window#requestFeature(int)).

<br />

|                                                             Parameters                                                             ||
|-------------|-----------------------------------------------------------------------------------------------------------------------|
| `featureId` | `int`: The desired feature as defined in[Window](https://developer.android.com/reference/android/view/Window). <br /> |

|                                        Returns                                        ||
|-----------|----------------------------------------------------------------------------|
| `boolean` | Returns true if the requested feature is supported and now enabled. <br /> |

**See also:**

- [Window.requestFeature(int)](https://developer.android.com/reference/android/view/Window#requestFeature(int))  

### requireViewById

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

```
public final T requireViewById (int id)
```

Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).

**Note:**In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

<br />

|                Parameters                ||
|------|------------------------------------|
| `id` | `int`: the ID to search for <br /> |

|                           Returns                            ||
|-----|---------------------------------------------------------|
| `T` | a view with given ID This value cannot be`null`. <br /> |

**See also:**

- [View.requireViewById(int)](https://developer.android.com/reference/android/view/View#requireViewById(int))
- [findViewById(int)](https://developer.android.com/reference/android/app/Dialog#findViewById(int))  

### setCancelMessage

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

```
public void setCancelMessage (Message msg)
```

Set a message to be sent when the dialog is canceled.

<br />

|                                           Parameters                                           ||
|-------|-----------------------------------------------------------------------------------------|
| `msg` | `Message`: The msg to send when the dialog is canceled. This value may be`null`. <br /> |

**See also:**

- [setOnCancelListener(android.content.DialogInterface.OnCancelListener)](https://developer.android.com/reference/android/app/Dialog#setOnCancelListener(android.content.DialogInterface.OnCancelListener))  

### setCancelable

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

```
public void setCancelable (boolean flag)
```

Sets whether this dialog is cancelable with the[BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)key.

<br />

|        Parameters        ||
|--------|------------------|
| `flag` | `boolean` <br /> |

### setCanceledOnTouchOutside

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

```
public void setCanceledOnTouchOutside (boolean cancel)
```

Sets whether this dialog is canceled when touched outside the window's bounds. If setting to true, the dialog is set to be cancelable if not already set.

<br />

|                                             Parameters                                             ||
|----------|------------------------------------------------------------------------------------------|
| `cancel` | `boolean`: Whether the dialog should be canceled when touched outside the window. <br /> |

### setContentView

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

```
public void setContentView (int layoutResID)
```

Set the screen content from a layout resource. The resource will be inflated, adding all top-level views to the screen.

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `layoutResID` | `int`: Resource ID to be inflated. <br /> |

### setContentView

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

```
public void setContentView (View view, 
                ViewGroup.LayoutParams params)
```

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.

<br />

|                                             Parameters                                              ||
|----------|-------------------------------------------------------------------------------------------|
| `view`   | `View`: The desired content to display. This value cannot be`null`. <br />                |
| `params` | `ViewGroup.LayoutParams`: Layout parameters for the view. This value may be`null`. <br /> |

### setContentView

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

```
public void setContentView (View view)
```

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.

<br />

|                                     Parameters                                     ||
|--------|----------------------------------------------------------------------------|
| `view` | `View`: The desired content to display. This value cannot be`null`. <br /> |

### setDismissMessage

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

```
public void setDismissMessage (Message msg)
```

Set a message to be sent when the dialog is dismissed.

<br />

|                                           Parameters                                            ||
|-------|------------------------------------------------------------------------------------------|
| `msg` | `Message`: The msg to send when the dialog is dismissed. This value may be`null`. <br /> |

### setFeatureDrawable

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

```
public final void setFeatureDrawable (int featureId, 
                Drawable drawable)
```

Convenience for calling[Window.setFeatureDrawable(int, Drawable)](https://developer.android.com/reference/android/view/Window#setFeatureDrawable(int,%20android.graphics.drawable.Drawable)).

<br />

|                        Parameters                        ||
|-------------|---------------------------------------------|
| `featureId` | `int` <br />                                |
| `drawable`  | `Drawable`: This value may be`null`. <br /> |

### setFeatureDrawableAlpha

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

```
public final void setFeatureDrawableAlpha (int featureId, 
                int alpha)
```

Convenience for calling[Window.setFeatureDrawableAlpha(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableAlpha(int,%20int)).

<br />

|        Parameters         ||
|-------------|--------------|
| `featureId` | `int` <br /> |
| `alpha`     | `int` <br /> |

### setFeatureDrawableResource

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

```
public final void setFeatureDrawableResource (int featureId, 
                int resId)
```

Convenience for calling[Window.setFeatureDrawableResource(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableResource(int,%20int)).

<br />

|        Parameters         ||
|-------------|--------------|
| `featureId` | `int` <br /> |
| `resId`     | `int` <br /> |

### setFeatureDrawableUri

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

```
public final void setFeatureDrawableUri (int featureId, 
                Uri uri)
```

Convenience for calling[Window.setFeatureDrawableUri(int, Uri)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableUri(int,%20android.net.Uri)).

<br />

|                     Parameters                      ||
|-------------|----------------------------------------|
| `featureId` | `int` <br />                           |
| `uri`       | `Uri`: This value may be`null`. <br /> |

### setOnCancelListener

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

```
public void setOnCancelListener (DialogInterface.OnCancelListener listener)
```

Set a listener to be invoked when the dialog is canceled.

This will only be invoked when the dialog is canceled. Cancel events alone will not capture all ways that the dialog might be dismissed. If the creator needs to know when a dialog is dismissed in general, use[setOnDismissListener(OnDismissListener)](https://developer.android.com/reference/android/app/Dialog#setOnDismissListener(android.content.DialogInterface.OnDismissListener)).

<br />

<br />

|                                                                                                       Parameters                                                                                                       ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener` | `DialogInterface.OnCancelListener`: The[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)to use. This value may be`null`. <br /> |

### setOnDismissListener

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

```
public void setOnDismissListener (DialogInterface.OnDismissListener listener)
```

Set a listener to be invoked when the dialog is dismissed.

<br />

|                                                                                                        Parameters                                                                                                         ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener` | `DialogInterface.OnDismissListener`: The[DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener)to use. This value may be`null`. <br /> |

### setOnKeyListener

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

```
public void setOnKeyListener (DialogInterface.OnKeyListener onKeyListener)
```

Sets the callback that will be called if a key is dispatched to the dialog.

<br />

|                                    Parameters                                     ||
|-----------------|------------------------------------------------------------------|
| `onKeyListener` | `DialogInterface.OnKeyListener`: This value may be`null`. <br /> |

### setOnShowListener

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

```
public void setOnShowListener (DialogInterface.OnShowListener listener)
```

Sets a listener to be invoked when the dialog is shown.

<br />

|                                                                                                    Parameters                                                                                                    ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener` | `DialogInterface.OnShowListener`: The[DialogInterface.OnShowListener](https://developer.android.com/reference/android/content/DialogInterface.OnShowListener)to use. This value may be`null`. <br /> |

### setOwnerActivity

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

```
public final void setOwnerActivity (Activity activity)
```

Sets the Activity that owns this dialog. An example use: This Dialog will use the suggested volume control stream of the Activity.

<br />

|                                           Parameters                                           ||
|------------|------------------------------------------------------------------------------------|
| `activity` | `Activity`: The Activity that owns this dialog. This value cannot be`null`. <br /> |

### setTitle

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

```
public void setTitle (CharSequence title)
```

Set the title text for this dialog's window.

<br />

|                                           Parameters                                           ||
|---------|---------------------------------------------------------------------------------------|
| `title` | `CharSequence`: The new text to display in the title. This value may be`null`. <br /> |

### setTitle

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

```
public void setTitle (int titleId)
```

Set the title text for this dialog's window. The text is retrieved from the resources with the supplied identifier.

<br />

|                          Parameters                           ||
|-----------|----------------------------------------------------|
| `titleId` | `int`: the title's text resource identifier <br /> |

### setVolumeControlStream

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

```
public final void setVolumeControlStream (int streamType)
```

By default, this will use the owner Activity's suggested stream type.

<br />

|         Parameters         ||
|--------------|--------------|
| `streamType` | `int` <br /> |

**See also:**

- [Activity.setVolumeControlStream(int)](https://developer.android.com/reference/android/app/Activity#setVolumeControlStream(int))
- [setOwnerActivity(Activity)](https://developer.android.com/reference/android/app/Dialog#setOwnerActivity(android.app.Activity))  

### show

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

```
public void show ()
```

Start the dialog and display it on screen. The window is placed in the application layer and opaque. Note that you should not override this method to do initialization when the dialog is shown, instead implement that in[onStart()](https://developer.android.com/reference/android/app/Dialog#onStart()).

<br />

### takeKeyEvents

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

```
public void takeKeyEvents (boolean get)
```

Request that key events come to this dialog. Use this if your dialog has no views with focus, but the dialog still wants a chance to process key events.

<br />

|                                       Parameters                                       ||
|-------|---------------------------------------------------------------------------------|
| `get` | `boolean`: true if the dialog should receive key events, false otherwise <br /> |

**See also:**

- [Window.takeKeyEvents(boolean)](https://developer.android.com/reference/android/view/Window#takeKeyEvents(boolean))  

### unregisterForContextMenu

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

```
public void unregisterForContextMenu (View view)
```

<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `view` | `View`: This value cannot be`null`. <br /> |

**See also:**

- [Activity.unregisterForContextMenu(View)](https://developer.android.com/reference/android/app/Activity#unregisterForContextMenu(android.view.View))

## Protected methods

### onCreate

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

```
protected void onCreate (Bundle savedInstanceState)
```

Similar to[Activity.onCreate](https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)), you should initialize your dialog in this method, including calling[setContentView(View)](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View)).

<br />

|                                                                                                                                                           Parameters                                                                                                                                                           ||
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `savedInstanceState` | `Bundle`: If this dialog is being reinitialized after a the hosting activity was previously shut down, holds the result from the most recent call to[onSaveInstanceState()](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState()), or null if this is the first time. <br /> |

### onStart

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

```
protected void onStart ()
```

Called when the dialog is starting.

<br />

### onStop

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

```
protected void onStop ()
```

Called to tell you that you're stopping.

<br />