# Window.Callback

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

# Callback

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/view/Window.Callback "View this page in Java")  

```
interface Callback
```

|--------------------------------------------------------------------------------------------------------------|
| [android.view.Window.Callback](https://developer.android.com/reference/kotlin/android/view/Window.Callback#) |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#),[Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#),[DreamService](https://developer.android.com/reference/kotlin/android/service/dreams/DreamService.html#) |----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------| | [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#)                    | An activity is a single, focused thing that the user can do.                           | | [Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#)                        | Base class for Dialogs.                                                                | | [DreamService](https://developer.android.com/reference/kotlin/android/service/dreams/DreamService.html#) | Extend this class to implement a custom dream (available to the user as a "Daydream"). | |

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#),[ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#),[AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#),[AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#),[CharacterPickerDialog](https://developer.android.com/reference/kotlin/android/text/method/CharacterPickerDialog.html#),[DatePickerDialog](https://developer.android.com/reference/kotlin/android/app/DatePickerDialog.html#),[ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#),[LauncherActivity](https://developer.android.com/reference/kotlin/android/app/LauncherActivity.html#),[ListActivity](https://developer.android.com/reference/kotlin/android/app/ListActivity.html#),[NativeActivity](https://developer.android.com/reference/kotlin/android/app/NativeActivity.html#),[PreferenceActivity](https://developer.android.com/reference/kotlin/android/preference/PreferenceActivity.html#),[Presentation](https://developer.android.com/reference/kotlin/android/app/Presentation.html#), and 3 others. |------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#) | Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator.                                                                                                                                                                                                                                                                                                             | | [ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#)                                    | A screen that contains and runs multiple embedded activities.                                                                                                                                                                                                                                                                                                                                                       | | [AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#)                                        | A subclass of Dialog that can display one, two or three buttons.                                                                                                                                                                                                                                                                                                                                                    | | [AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#)                                    | Stub activity that launches another activity (and then finishes itself) based on information in its component's manifest meta-data.                                                                                                                                                                                                                                                                                 | | [CharacterPickerDialog](https://developer.android.com/reference/kotlin/android/text/method/CharacterPickerDialog.html#)            | Dialog for choosing accented characters related to a base character.                                                                                                                                                                                                                                                                                                                                                | | [DatePickerDialog](https://developer.android.com/reference/kotlin/android/app/DatePickerDialog.html#)                              | A simple dialog containing an[android.widget.DatePicker](https://developer.android.com/reference/kotlin/android/widget/DatePicker.html#).                                                                                                                                                                                                                                                                           | | [ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#)                  | An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item.                                                                                                                                                                                                                                 | | [LauncherActivity](https://developer.android.com/reference/kotlin/android/app/LauncherActivity.html#)                              | Displays a list of all activities which can be performed for a given intent.                                                                                                                                                                                                                                                                                                                                        | | [ListActivity](https://developer.android.com/reference/kotlin/android/app/ListActivity.html#)                                      | An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.                                                                                                                                                                                                                                                         | | [NativeActivity](https://developer.android.com/reference/kotlin/android/app/NativeActivity.html#)                                  | Convenience for implementing an activity that will be implemented purely in native code.                                                                                                                                                                                                                                                                                                                            | | [PreferenceActivity](https://developer.android.com/reference/kotlin/android/preference/PreferenceActivity.html#)                   | This is the base class for an activity to show a hierarchy of preferences to the user.                                                                                                                                                                                                                                                                                                                              | | [Presentation](https://developer.android.com/reference/kotlin/android/app/Presentation.html#)                                      | Base class for presentations.                                                                                                                                                                                                                                                                                                                                                                                       | | [ProgressDialog](https://developer.android.com/reference/kotlin/android/app/ProgressDialog.html#)                                  | A dialog showing a progress indicator and an optional text message or view.                                                                                                                                                                                                                                                                                                                                         | | [TabActivity](https://developer.android.com/reference/kotlin/android/app/TabActivity.html#)                                        | For apps developing against[android.os.Build.VERSION_CODES#HONEYCOMB](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#HONEYCOMB:kotlin.Int)or later, tabs are typically presented in the UI using the new[ActionBar.newTab()](https://developer.android.com/reference/kotlin/android/app/ActionBar.html#newTab())and related APIs for placing tabs within their action bar area. | | [TimePickerDialog](https://developer.android.com/reference/kotlin/android/app/TimePickerDialog.html#)                              | A dialog that prompts the user for the time of day using a[TimePicker](https://developer.android.com/reference/kotlin/android/widget/TimePicker.html#).                                                                                                                                                                                                                                                             | |

API from a Window back to its caller. This allows the client to intercept key dispatching, panels and menus, etc.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                        Public methods                                                                                                                                                                                                                                                                                                                                                                                         ||
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchGenericMotionEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchGenericMotionEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!`)` Called to process generic motion events.                                                                                                                                                                                                                                                                                                                                                                                  |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchKeyEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchKeyEvent(android.view.KeyEvent))`(`event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!`)` Called to process key events.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchKeyShortcutEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchKeyShortcutEvent(android.view.KeyEvent))`(`event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!`)` Called to process a key shortcut event.                                                                                                                                                                                                                                                                                                                                                                                                |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent))`(`event:` `[AccessibilityEvent](https://developer.android.com/reference/kotlin/android/view/accessibility/AccessibilityEvent)!`)` Called to process population of[AccessibilityEvent](https://developer.android.com/reference/kotlin/android/view/accessibility/AccessibilityEvent)s.                                                                                                                                                                                                      |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchTouchEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchTouchEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!`)` Called to process touch screen events.                                                                                                                                                                                                                                                                                                                                                                                                    |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [dispatchTrackballEvent](https://developer.android.com/reference/kotlin/android/view/Window.Callback#dispatchTrackballEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!`)` Called to process trackball events.                                                                                                                                                                                                                                                                                                                                                                                               |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onActionModeFinished](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onActionModeFinished(android.view.ActionMode))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`)` Called when an action mode has been finished.                                                                                                                                                                                                                                                                                                                                                                                             |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onActionModeStarted](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onActionModeStarted(android.view.ActionMode))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`)` Called when an action mode has been started.                                                                                                                                                                                                                                                                                                                                                                                                |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onAttachedToWindow](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onAttachedToWindow())`()` Called when the window has been attached to the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onContentChanged](https://developer.android.com/reference/kotlin/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/kotlin/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/kotlin/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).                                                                                                                                       |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onCreatePanelMenu](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onCreatePanelMenu(kotlin.Int,%20android.view.Menu))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)`)` Initialize the contents of the menu for panel 'featureId'.                                                                                                                                                                                                                                                                                                |
| abstract[View](https://developer.android.com/reference/kotlin/android/view/View)?             | [onCreatePanelView](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onCreatePanelView(kotlin.Int))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Instantiate the view to display in the panel for 'featureId'.                                                                                                                                                                                                                                                                                                                                                                                                      |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onDetachedFromWindow](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onDetachedFromWindow())`()` Called when the window has been detached from the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onMenuItemSelected](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onMenuItemSelected(kotlin.Int,%20android.view.MenuItem))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `item:` `[MenuItem](https://developer.android.com/reference/kotlin/android/view/MenuItem)`)` Called when a panel's menu item has been selected by the user.                                                                                                                                                                                                                                                                              |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onMenuOpened](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onMenuOpened(kotlin.Int,%20android.view.Menu))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)`)` Called when a panel's menu is opened by the user.                                                                                                                                                                                                                                                                                                                   |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onPanelClosed](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onPanelClosed(kotlin.Int,%20android.view.Menu))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)`)` Called when a panel is being closed.                                                                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)              | [onPointerCaptureChanged](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onPointerCaptureChanged(kotlin.Boolean))`(`hasCapture:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Called when pointer capture is enabled or disabled for the current window.                                                                                                                                                                                                                                                                                                                                                                |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onPreparePanel](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onPreparePanel(kotlin.Int,%20android.view.View,%20android.view.Menu))`(`featureId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `view:` `[View](https://developer.android.com/reference/kotlin/android/view/View)?`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)`)` Prepare a panel to be displayed.                                                                                                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)              | [onProvideKeyboardShortcuts](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onProvideKeyboardShortcuts(kotlin.collections.MutableList,%20android.view.Menu,%20kotlin.Int))`(`data:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[KeyboardShortcutGroup](https://developer.android.com/reference/kotlin/android/view/KeyboardShortcutGroup)!>!`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)?`, `deviceId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when Keyboard Shortcuts are requested for the current window. |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onSearchRequested](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onSearchRequested())`()` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)    | [onSearchRequested](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onSearchRequested(android.view.SearchEvent))`(`searchEvent:` `[SearchEvent](https://developer.android.com/reference/kotlin/android/view/SearchEvent)!`)` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                            |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onWindowAttributesChanged](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onWindowAttributesChanged(android.view.WindowManager.LayoutParams))`(`attrs:` `[WindowManager.LayoutParams](https://developer.android.com/reference/kotlin/android/view/WindowManager.LayoutParams)!`)` This is called whenever the current window attributes change.                                                                                                                                                                                                                                                                                                                  |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)          | [onWindowFocusChanged](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onWindowFocusChanged(kotlin.Boolean))`(`hasFocus:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` This hook is called whenever the window focus changes.                                                                                                                                                                                                                                                                                                                                                                                            |
| abstract[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)? | [onWindowStartingActionMode](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback))`(`callback:` `[ActionMode.Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback)!`)` Called when an action mode is being started for this window.                                                                                                                                                                                                                                                                                                                                   |
| abstract[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)? | [onWindowStartingActionMode](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback,%20kotlin.Int))`(`callback:` `[ActionMode.Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback)!`, `type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when an action mode is being started for this window.                                                                                                                                                                                                                               |

## Public methods

### dispatchGenericMotionEvent

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

```
abstract fun dispatchGenericMotionEvent(event: MotionEvent!): Boolean
```

Called to process generic motion events. At the very least your implementation must call[android.view.Window#superDispatchGenericMotionEvent](https://developer.android.com/reference/kotlin/android/view/Window#superDispatchGenericMotionEvent(android.view.MotionEvent))to do the standard processing.

|                                                         Parameters                                                         ||
|---------|-------------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!:The generic motion event. |

|                                                               Return                                                                ||
|------------------------------------------------------------------------------------|-------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Return true if this event was consumed. |

### dispatchKeyEvent

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

```
abstract fun dispatchKeyEvent(event: KeyEvent!): Boolean
```

Called to process key events. At the very least your implementation must call[android.view.Window#superDispatchKeyEvent](https://developer.android.com/reference/kotlin/android/view/Window#superDispatchKeyEvent(android.view.KeyEvent))to do the standard key processing.

|                                                Parameters                                                 ||
|---------|--------------------------------------------------------------------------------------------------|
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!:The key event. |

|                                                               Return                                                                ||
|------------------------------------------------------------------------------------|-------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Return true if this event was consumed. |

### dispatchKeyShortcutEvent

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

```
abstract fun dispatchKeyShortcutEvent(event: KeyEvent!): Boolean
```

Called to process a key shortcut event. At the very least your implementation must call[android.view.Window#superDispatchKeyShortcutEvent](https://developer.android.com/reference/kotlin/android/view/Window#superDispatchKeyShortcutEvent(android.view.KeyEvent))to do the standard key shortcut processing.

|                                                     Parameters                                                     ||
|---------|-----------------------------------------------------------------------------------------------------------|
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!:The key shortcut event. |

|                                                        Return                                                        ||
|------------------------------------------------------------------------------------|----------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | True if this event was consumed. |

### dispatchPopulateAccessibilityEvent

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

```
abstract fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent!): Boolean
```

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

|                                                               Parameters                                                                ||
|---------|--------------------------------------------------------------------------------------------------------------------------------|
| `event` | [AccessibilityEvent](https://developer.android.com/reference/kotlin/android/view/accessibility/AccessibilityEvent)!:The event. |

|                                                                   Return                                                                   ||
|------------------------------------------------------------------------------------|--------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Return true if event population was completed. |

### dispatchTouchEvent

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

```
abstract fun dispatchTouchEvent(event: MotionEvent!): Boolean
```

Called to process touch screen events. At the very least your implementation must call[android.view.Window#superDispatchTouchEvent](https://developer.android.com/reference/kotlin/android/view/Window#superDispatchTouchEvent(android.view.MotionEvent))to do the standard touch screen processing.

|                                                        Parameters                                                        ||
|---------|-----------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!:The touch screen event. |

|                                                               Return                                                                ||
|------------------------------------------------------------------------------------|-------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Return true if this event was consumed. |

### dispatchTrackballEvent

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

```
abstract fun dispatchTrackballEvent(event: MotionEvent!): Boolean
```

Called to process trackball events. At the very least your implementation must call[android.view.Window#superDispatchTrackballEvent](https://developer.android.com/reference/kotlin/android/view/Window#superDispatchTrackballEvent(android.view.MotionEvent))to do the standard trackball processing.

|                                                      Parameters                                                       ||
|---------|--------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent)!:The trackball event. |

|                                                               Return                                                                ||
|------------------------------------------------------------------------------------|-------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Return true if this event was consumed. |

### onActionModeFinished

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

```
abstract fun onActionModeFinished(mode: ActionMode!): Unit
```

Called when an action mode has been finished. The appropriate mode callback method will have already been invoked.

|                                                           Parameters                                                           ||
|--------|------------------------------------------------------------------------------------------------------------------------|
| `mode` | [ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!:The mode that was just finished. |

### onActionModeStarted

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

```
abstract fun onActionModeStarted(mode: ActionMode!): Unit
```

Called when an action mode has been started. The appropriate mode callback method will have already been invoked.

|                                                               Parameters                                                               ||
|--------|--------------------------------------------------------------------------------------------------------------------------------|
| `mode` | [ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!:The new mode that has just been started. |

### onAttachedToWindow

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

```
abstract fun onAttachedToWindow(): Unit
```

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

### onContentChanged

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

```
abstract fun onContentChanged(): Unit
```

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

### onCreatePanelMenu

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

```
abstract fun onCreatePanelMenu(
    featureId: Int, 
    menu: Menu
): Boolean
```

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 menu (and any items created from it), making modifications to it as desired, until the next time onCreatePanelMenu() is called for this feature.

|                                                                  Parameters                                                                  ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The panel being created.                             |
| `menu`      | [Menu](https://developer.android.com/reference/kotlin/android/view/Menu):The menu inside the panel. This value cannot be`null`. |

|                                                                                          Return                                                                                           ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean You must return true for the panel to be displayed; if you return false it will not be shown. |

### onCreatePanelView

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

```
abstract fun onCreatePanelView(featureId: Int): View?
```

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.

|                                                      Parameters                                                       ||
|-------------|----------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Which panel is being created. |

|                                                          Return                                                           ||
|---------------------------------------------------------------------------|------------------------------------------------|
| [View](https://developer.android.com/reference/kotlin/android/view/View)? | view The top-level view to place in the panel. |

**See Also**

- [#onPreparePanel](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onPreparePanel(kotlin.Int,%20android.view.View,%20android.view.Menu))  

### onDetachedFromWindow

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

```
abstract fun onDetachedFromWindow(): Unit
```

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

### onMenuItemSelected

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

```
abstract fun onMenuItemSelected(
    featureId: Int, 
    item: MenuItem
): Boolean
```

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

|                                                                         Parameters                                                                         ||
|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The panel that the menu is in.                                     |
| `item`      | [MenuItem](https://developer.android.com/reference/kotlin/android/view/MenuItem):The menu item that was selected. This value cannot be`null`. |

|                                                                                                                           Return                                                                                                                           ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | 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). |

### onMenuOpened

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

```
abstract fun onMenuOpened(
    featureId: Int, 
    menu: Menu
): Boolean
```

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).

|                                                                 Parameters                                                                 ||
|-------------|-------------------------------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The panel that the menu is in.                     |
| `menu`      | [Menu](https://developer.android.com/reference/kotlin/android/view/Menu):The menu that is opened. This value cannot be`null`. |

|                                                                                Return                                                                                 ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | Return true to allow the menu to open, or false to prevent the menu from opening. |

### onPanelClosed

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

```
abstract fun onPanelClosed(
    featureId: Int, 
    menu: Menu
): Unit
```

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.

|                                                                                 Parameters                                                                                 ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The panel that is being displayed.                                                 |
| `menu`      | [Menu](https://developer.android.com/reference/kotlin/android/view/Menu):If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |

### onPointerCaptureChanged

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

```
open fun onPointerCaptureChanged(hasCapture: Boolean): Unit
```

Called when pointer capture is enabled or disabled for the current window.

|                                                                Parameters                                                                ||
|--------------|----------------------------------------------------------------------------------------------------------------------------|
| `hasCapture` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):True if the window has pointer capture. |

### onPreparePanel

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

```
abstract fun onPreparePanel(
    featureId: Int, 
    view: View?, 
    menu: Menu
): Boolean
```

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

|                                                                                 Parameters                                                                                 ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `featureId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The panel that is being displayed.                                                 |
| `view`      | [View](https://developer.android.com/reference/kotlin/android/view/View)?:The View that was returned by onCreatePanelView(). This value may be`null`.         |
| `menu`      | [Menu](https://developer.android.com/reference/kotlin/android/view/Menu):If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |

|                                                                                          Return                                                                                           ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean You must return true for the panel to be displayed; if you return false it will not be shown. |

**See Also**

- [#onCreatePanelView](https://developer.android.com/reference/kotlin/android/view/Window.Callback#onCreatePanelView(kotlin.Int))  

### onProvideKeyboardShortcuts

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

```
open fun onProvideKeyboardShortcuts(
    data: MutableList<KeyboardShortcutGroup!>!, 
    menu: Menu?, 
    deviceId: Int
): Unit
```

Called when Keyboard Shortcuts are requested for the current window.

|                                                                                                                                  Parameters                                                                                                                                   ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `data`     | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[KeyboardShortcutGroup](https://developer.android.com/reference/kotlin/android/view/KeyboardShortcutGroup)!\>!:The data list to populate with shortcuts. |
| `menu`     | [Menu](https://developer.android.com/reference/kotlin/android/view/Menu)?:The current menu, which may be null.                                                                                                                                                    |
| `deviceId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The id for the connected device the shortcuts should be provided for.                                                                                                                  |

### onSearchRequested

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

```
abstract fun onSearchRequested(): Boolean
```

Called when the user signals the desire to start a search.

|                                                                     Return                                                                      ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if search launched, false if activity refuses (blocks) |

**See Also**

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

### onSearchRequested

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

```
abstract fun onSearchRequested(searchEvent: SearchEvent!): Boolean
```

Called when the user signals the desire to start a search.

|                                                                                                               Parameters                                                                                                               ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `searchEvent` | [SearchEvent](https://developer.android.com/reference/kotlin/android/view/SearchEvent)!:A[SearchEvent](https://developer.android.com/reference/kotlin/android/view/SearchEvent)describing the signal to start a search. |

|                                                                     Return                                                                      ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if search launched, false if activity refuses (blocks) |

### onWindowAttributesChanged

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

```
abstract fun onWindowAttributesChanged(attrs: WindowManager.LayoutParams!): Unit
```

This is called whenever the current window attributes change.  

### onWindowFocusChanged

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

```
abstract fun onWindowFocusChanged(hasFocus: Boolean): Unit
```

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

|                                                            Parameters                                                            ||
|------------|----------------------------------------------------------------------------------------------------------------------|
| `hasFocus` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether the window now has focus. |

### onWindowStartingActionMode

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

```
abstract fun onWindowStartingActionMode(callback: ActionMode.Callback!): ActionMode?
```

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/kotlin/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback,%20kotlin.Int))with type[ActionMode.TYPE_PRIMARY](https://developer.android.com/reference/kotlin/android/view/ActionMode#TYPE_PRIMARY:kotlin.Int).

|                                                                                Parameters                                                                                 ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callback` | [ActionMode.Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback)!:Callback to control the lifecycle of this action mode |

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

### onWindowStartingActionMode

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

```
abstract fun onWindowStartingActionMode(
    callback: ActionMode.Callback!, 
    type: Int
): ActionMode?
```

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.

|                                                                                                                                                                      Parameters                                                                                                                                                                      ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callback` | [ActionMode.Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback)!:Callback to control the lifecycle of this action mode                                                                                                                                                                            |
| `type`     | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):One of[ActionMode.TYPE_PRIMARY](https://developer.android.com/reference/kotlin/android/view/ActionMode#TYPE_PRIMARY:kotlin.Int)or[ActionMode.TYPE_FLOATING](https://developer.android.com/reference/kotlin/android/view/ActionMode#TYPE_FLOATING:kotlin.Int). |

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