# ComponentDialog

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/ComponentDialog.kt+class:androidx.activity.ComponentDialog) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

*** ** * ** ***

<br />

```
open class ComponentDialog : Dialog, LifecycleOwner, OnBackPressedDispatcherOwner, NavigationEventDispatcherOwner, SavedStateRegistryOwner
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html) ||
|   | ↳ | [androidx.activity.ComponentDialog](https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog) |

Known direct subclasses [AppCompatDialog](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog` | Base class for AppCompat themed `https://developer.android.com/reference/android/app/Dialog.html`s. |

Known indirect subclasses [AlertDialog](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog), [MediaRouteChooserDialog](https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteChooserDialog), [MediaRouteControllerDialog](https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteControllerDialog)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` | A subclass of Dialog that can display one, two or three buttons. |
| `https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteChooserDialog` | This class implements the route chooser dialog for `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter`. |
| `https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteControllerDialog` | This class implements the route controller dialog for `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter`. |

*** ** * ** ***

Base class for dialogs that enables composition of higher level components.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#ComponentDialog(android.content.Context,kotlin.Int)(context: https://developer.android.com/reference/android/content/Context.html, themeResId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#addContentView(android.view.View,android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#initializeViewTreeOwners()()` Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper [onBackPressed](https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed())()` **This function is deprecated.** This method has been deprecated in favor of using the {@link OnBackPressedDispatcher} via {@link #getOnBackPressedDispatcher()}. |
| `open https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onSaveInstanceState()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#setContentView(kotlin.Int)(layoutResID: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#setContentView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#setContentView(android.view.View,android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html?)` |

| ### Protected functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onCreate(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onStart()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onStop()()` |

| ### Public properties |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#lifecycle()` |
| `open https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#navigationEventDispatcher()` Lazily provides a `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` for back navigation handling, including support for predictive back gestures introduced in Android 13 (API 33+). |
| `final https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressedDispatcher()` Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` that will be triggered when `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed()` is called. |
| `open https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistry` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#savedStateRegistry()` |

### Inherited functions

From [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#cancel()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#closeOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#create()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dismiss()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchGenericMotionEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchKeyEvent(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchKeyShortcutEvent(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)(event: https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchTouchEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchTrackballEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html)` `T` `<T : https://developer.android.com/reference/android/view/View.html> https://developer.android.com/reference/android/app/Dialog.html#findViewById(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#hide()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#invalidateOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onActionModeFinished(android.view.ActionMode)(mode: https://developer.android.com/reference/android/view/ActionMode.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onActionModeStarted(android.view.ActionMode)(mode: https://developer.android.com/reference/android/view/ActionMode.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onAttachedToWindow()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContentChanged()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContextItemSelected(android.view.MenuItem)(item: https://developer.android.com/reference/android/view/MenuItem.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContextMenuClosed(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)(

menu: https://developer.android.com/reference/android/view/ContextMenu.html,

v: https://developer.android.com/reference/android/view/View.html,

menuInfo: https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html

)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreateOptionsMenu(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreatePanelMenu(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html)` `https://developer.android.com/reference/android/view/View.html?` `https://developer.android.com/reference/android/app/Dialog.html#onCreatePanelView(int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onDetachedFromWindow()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onGenericMotionEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyDown(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyLongPress(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyMultiple(int, int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, repeatCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyShortcut(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyUp(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onMenuItemSelected(int, android.view.MenuItem)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item: https://developer.android.com/reference/android/view/MenuItem.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onMenuOpened(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onOptionsItemSelected(android.view.MenuItem)(item: https://developer.android.com/reference/android/view/MenuItem.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onOptionsMenuClosed(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPanelClosed(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPrepareOptionsMenu(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPreparePanel(int, android.view.View, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, view: https://developer.android.com/reference/android/view/View.html?, menu: https://developer.android.com/reference/android/view/Menu.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onRestoreInstanceState(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onSearchRequested()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onSearchRequested(android.view.SearchEvent)(searchEvent: https://developer.android.com/reference/android/view/SearchEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onTouchEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onTrackballEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onWindowAttributesChanged(android.view.WindowManager.LayoutParams)(params: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onWindowFocusChanged(boolean)(hasFocus: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://developer.android.com/reference/android/view/ActionMode.html?` `https://developer.android.com/reference/android/app/Dialog.html#onWindowStartingActionMode(android.view.ActionMode.Callback)(callback: https://developer.android.com/reference/android/view/ActionMode.Callback.html)` `https://developer.android.com/reference/android/view/ActionMode.html?` `https://developer.android.com/reference/android/app/Dialog.html#onWindowStartingActionMode(android.view.ActionMode.Callback, int)(callback: https://developer.android.com/reference/android/view/ActionMode.Callback.html, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#openContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#openOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#registerForContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#requestWindowFeature(int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `T` `<T : https://developer.android.com/reference/android/view/View.html> https://developer.android.com/reference/android/app/Dialog.html#requireViewById(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCancelMessage(android.os.Message)(msg: https://developer.android.com/reference/android/os/Message.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCancelable(boolean)(flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCanceledOnTouchOutside(boolean)(cancel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setDismissMessage(android.os.Message)(msg: https://developer.android.com/reference/android/os/Message.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawable(int, android.graphics.drawable.Drawable)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, drawable: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableAlpha(int, int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableResource(int, int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableUri(int, android.net.Uri)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, uri: https://developer.android.com/reference/android/net/Uri.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnCancelListener(android.content.DialogInterface.OnCancelListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnDismissListener(android.content.DialogInterface.OnDismissListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnKeyListener(android.content.DialogInterface.OnKeyListener)(onKeyListener: https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnShowListener(android.content.DialogInterface.OnShowListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnShowListener.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOwnerActivity(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setTitle(int)(titleId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#show()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#takeKeyEvents(boolean)(get: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#unregisterForContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` From [android.view.Window.Callback](https://developer.android.com/reference/android/view/Window.Callback.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/view/Window.Callback.html#onPointerCaptureChanged(boolean)(hasCapture: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/view/Window.Callback.html#onProvideKeyboardShortcuts(java.util.List&lt;android.view.KeyboardShortcutGroup&gt;, android.view.Menu, int)(

data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/android/view/KeyboardShortcutGroup.html>,

menu: https://developer.android.com/reference/android/view/Menu.html?,

deviceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html

)`

### Inherited properties

From [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html) `open https://developer.android.com/reference/android/app/ActionBar.html?` `https://developer.android.com/reference/android/app/Dialog.html#actionBar` `https://developer.android.com/reference/android/content/Context.html` `https://developer.android.com/reference/android/app/Dialog.html#context` `open https://developer.android.com/reference/android/view/View.html?` `https://developer.android.com/reference/android/app/Dialog.html#currentFocus` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#isShowing` `open https://developer.android.com/reference/android/view/LayoutInflater.html` `https://developer.android.com/reference/android/app/Dialog.html#layoutInflater` `open https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html` `https://developer.android.com/reference/android/app/Dialog.html#onBackInvokedDispatcher` `https://developer.android.com/reference/android/app/Activity.html?` `https://developer.android.com/reference/android/app/Dialog.html#ownerActivity` `https://developer.android.com/reference/android/view/SearchEvent.html?` `https://developer.android.com/reference/android/app/Dialog.html#searchEvent` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/app/Dialog.html#volumeControlStream` `open https://developer.android.com/reference/android/view/Window.html?` `https://developer.android.com/reference/android/app/Dialog.html#window`

## Public constructors

### ComponentDialog

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
ComponentDialog(context: Context, themeResId: @StyleRes Int = 0)
```

## Public functions

### addContentView

```
open fun addContentView(view: View, params: ViewGroup.LayoutParams?): Unit
```

### initializeViewTreeOwners

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/activity#1.8.0)

```
@CallSuper
open fun initializeViewTreeOwners(): Unit
```

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.

### onBackPressed

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

```
@CallSuper
open fun [onBackPressed](https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> This method has been deprecated in favor of using the {@link OnBackPressedDispatcher} via {@link #getOnBackPressedDispatcher()}. The OnBackPressedDispatcher controls how back button events are dispatched to one or more {@link OnBackPressedCallback} objects.

### onSaveInstanceState

```
open fun onSaveInstanceState(): Bundle
```

### setContentView

```
open fun setContentView(layoutResID: Int): Unit
```

### setContentView

```
open fun setContentView(view: View): Unit
```

### setContentView

```
open fun setContentView(view: View, params: ViewGroup.LayoutParams?): Unit
```

## Protected functions

### onCreate

```
@CallSuper
protected open fun onCreate(savedInstanceState: Bundle?): Unit
```

### onStart

```
@CallSuper
protected open fun onStart(): Unit
```

### onStop

```
@CallSuper
protected open fun onStop(): Unit
```

## Public properties

### lifecycle

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
open val lifecycle: Lifecycle
```

### navigationEventDispatcher

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/activity#1.12.0)

```
open val navigationEventDispatcher: NavigationEventDispatcher
```

Lazily provides a `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` for back navigation handling, including support for predictive back gestures introduced in Android 13 (API 33+).

This dispatcher acts as the central point for back navigation events. When a navigation event occurs (e.g., a back gesture), it safely invokes `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed()`.

### onBackPressedDispatcher

```
final val onBackPressedDispatcher: OnBackPressedDispatcher
```

Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` that will be triggered when `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed()` is called.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` | The `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` associated with this ComponentDialog. |

### savedStateRegistry

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
open val savedStateRegistry: SavedStateRegistry
```