Window.Callback
public
static
interface
Window.Callback
android.view.Window.Callback |
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
|
dispatchGenericMotionEvent(MotionEvent event)
Called to process generic motion events. |
abstract
boolean
|
dispatchKeyEvent(KeyEvent event)
Called to process key events. |
abstract
boolean
|
dispatchKeyShortcutEvent(KeyEvent event)
Called to process a key shortcut event. |
abstract
boolean
|
dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
Called to process population of |
abstract
boolean
|
dispatchTouchEvent(MotionEvent event)
Called to process touch screen events. |
abstract
boolean
|
dispatchTrackballEvent(MotionEvent event)
Called to process trackball events. |
abstract
void
|
onActionModeFinished(ActionMode mode)
Called when an action mode has been finished. |
abstract
void
|
onActionModeStarted(ActionMode mode)
Called when an action mode has been started. |
abstract
void
|
onAttachedToWindow()
Called when the window has been attached to the window manager. |
abstract
void
|
onContentChanged()
This hook is called whenever the content view of the screen changes
(due to a call to
|
abstract
boolean
|
onCreatePanelMenu(int featureId, Menu menu)
Initialize the contents of the menu for panel 'featureId'. |
abstract
View
|
onCreatePanelView(int featureId)
Instantiate the view to display in the panel for 'featureId'. |
abstract
void
|
onDetachedFromWindow()
Called when the window has been detached from the window manager. |
abstract
boolean
|
onMenuItemSelected(int featureId, MenuItem item)
Called when a panel's menu item has been selected by the user. |
abstract
boolean
|
onMenuOpened(int featureId, Menu menu)
Called when a panel's menu is opened by the user. |
abstract
void
|
onPanelClosed(int featureId, Menu menu)
Called when a panel is being closed. |
default
void
|
onPointerCaptureChanged(boolean hasCapture)
Called when pointer capture is enabled or disabled for the current window. |
abstract
boolean
|
onPreparePanel(int featureId, View view, Menu menu)
Prepare a panel to be displayed. |
default
void
|
onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId)
Called when Keyboard Shortcuts are requested for the current window. |
abstract
boolean
|
onSearchRequested()
Called when the user signals the desire to start a search. |
abstract
boolean
|
onSearchRequested(SearchEvent searchEvent)
Called when the user signals the desire to start a search. |
abstract
void
|
onWindowAttributesChanged(WindowManager.LayoutParams attrs)
This is called whenever the current window attributes change. |
abstract
void
|
onWindowFocusChanged(boolean hasFocus)
This hook is called whenever the window focus changes. |
abstract
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback callback)
Called when an action mode is being started for this window. |
abstract
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback callback, int type)
Called when an action mode is being started for this window. |
Public methods
dispatchGenericMotionEvent
public abstract boolean dispatchGenericMotionEvent (MotionEvent event)
Called to process generic motion events. At the very least your
implementation must call
Window.superDispatchGenericMotionEvent(MotionEvent)
to do the
standard processing.
Parameters | |
---|---|
event |
MotionEvent : The generic motion event. |
Returns | |
---|---|
boolean |
boolean Return true if this event was consumed. |
dispatchKeyEvent
public abstract boolean dispatchKeyEvent (KeyEvent event)
Called to process key events. At the very least your
implementation must call
Window.superDispatchKeyEvent(KeyEvent)
to do the
standard key processing.
Parameters | |
---|---|
event |
KeyEvent : The key event. |
Returns | |
---|---|
boolean |
boolean Return true if this event was consumed. |
dispatchKeyShortcutEvent
public abstract boolean dispatchKeyShortcutEvent (KeyEvent event)
Called to process a key shortcut event.
At the very least your implementation must call
Window.superDispatchKeyShortcutEvent(KeyEvent)
to do the
standard key shortcut processing.
Parameters | |
---|---|
event |
KeyEvent : The key shortcut event. |
Returns | |
---|---|
boolean |
True if this event was consumed. |
dispatchPopulateAccessibilityEvent
public abstract boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
Called to process population of AccessibilityEvent
s.
Parameters | |
---|---|
event |
AccessibilityEvent : The event. |
Returns | |
---|---|
boolean |
boolean Return true if event population was completed. |
dispatchTouchEvent
public abstract boolean dispatchTouchEvent (MotionEvent event)
Called to process touch screen events. At the very least your
implementation must call
Window.superDispatchTouchEvent(MotionEvent)
to do the
standard touch screen processing.
Parameters | |
---|---|
event |
MotionEvent : The touch screen event. |
Returns | |
---|---|
boolean |
boolean Return true if this event was consumed. |
dispatchTrackballEvent
public abstract boolean dispatchTrackballEvent (MotionEvent event)
Called to process trackball events. At the very least your
implementation must call
Window.superDispatchTrackballEvent(MotionEvent)
to do the
standard trackball processing.
Parameters | |
---|---|
event |
MotionEvent : The trackball event. |
Returns | |
---|---|
boolean |
boolean Return true if this event was consumed. |
onActionModeFinished
public abstract void onActionModeFinished (ActionMode mode)
Called when an action mode has been finished. The appropriate mode callback method will have already been invoked.
Parameters | |
---|---|
mode |
ActionMode : The mode that was just finished. |
onActionModeStarted
public abstract void onActionModeStarted (ActionMode mode)
Called when an action mode has been started. The appropriate mode callback method will have already been invoked.
Parameters | |
---|---|
mode |
ActionMode : The new mode that has just been started. |
onAttachedToWindow
public abstract void onAttachedToWindow ()
Called when the window has been attached to the window manager.
See View.onAttachedToWindow()
for more information.
onContentChanged
public abstract void onContentChanged ()
This hook is called whenever the content view of the screen changes
(due to a call to
Window.setContentView
or
Window.addContentView
).
onCreatePanelMenu
public abstract boolean onCreatePanelMenu (int featureId, Menu menu)
Initialize the contents of the menu for panel 'featureId'. This is called if onCreatePanelView() returns null, giving you a standard menu in which you can place your items. It is only called once for the panel, the first time it is shown.
You can safely hold on to 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 : The panel being created. |
menu |
Menu : The menu inside the panel.
This value cannot be null . |
Returns | |
---|---|
boolean |
boolean You must return true for the panel to be displayed; if you return false it will not be shown. |
onCreatePanelView
public abstract View onCreatePanelView (int featureId)
Instantiate the view to display in the panel for 'featureId'. You can return null, in which case the default content (typically a menu) will be created for you.
Parameters | |
---|---|
featureId |
int : Which panel is being created. |
Returns | |
---|---|
View |
view The top-level view to place in the panel. |
See also:
onDetachedFromWindow
public abstract void onDetachedFromWindow ()
Called when the window has been detached from the window manager.
See View.onDetachedFromWindow()
for more information.
onMenuItemSelected
public abstract boolean onMenuItemSelected (int featureId, MenuItem item)
Called when a panel's menu item has been selected by the user.
Parameters | |
---|---|
featureId |
int : The panel that the menu is in. |
item |
MenuItem : The menu item that was selected.
This value cannot be null . |
Returns | |
---|---|
boolean |
boolean Return true to finish processing of selection, or false to perform the normal menu handling (calling its Runnable or sending a Message to its target Handler). |
onMenuOpened
public abstract boolean onMenuOpened (int featureId, Menu menu)
Called when a panel's menu is opened by the user. This may also be called when the menu is changing from one type to another (for example, from the icon menu to the expanded menu).
Parameters | |
---|---|
featureId |
int : The panel that the menu is in. |
menu |
Menu : The menu that is opened.
This value cannot be null . |
Returns | |
---|---|
boolean |
Return true to allow the menu to open, or false to prevent the menu from opening. |
onPanelClosed
public abstract void onPanelClosed (int featureId, Menu menu)
Called when a panel is being closed. If another logical subsequent panel is being opened (and this panel is being closed to make room for the subsequent panel), this method will NOT be called.
Parameters | |
---|---|
featureId |
int : The panel that is being displayed. |
menu |
Menu : If onCreatePanelView() returned null, this is the Menu
being displayed in the panel. |
onPointerCaptureChanged
public void onPointerCaptureChanged (boolean hasCapture)
Called when pointer capture is enabled or disabled for the current window.
Parameters | |
---|---|
hasCapture |
boolean : True if the window has pointer capture. |
onPreparePanel
public abstract boolean onPreparePanel (int featureId, View view, Menu menu)
Prepare a panel to be displayed. This is called right before the panel window is shown, every time it is shown.
Parameters | |
---|---|
featureId |
int : The panel that is being displayed. |
view |
View : The View that was returned by onCreatePanelView().
This value may be null . |
menu |
Menu : If onCreatePanelView() returned null, this is the Menu
being displayed in the panel. |
Returns | |
---|---|
boolean |
boolean You must return true for the panel to be displayed; if you return false it will not be shown. |
See also:
onProvideKeyboardShortcuts
public void onProvideKeyboardShortcuts (List<KeyboardShortcutGroup> data, Menu menu, int deviceId)
Called when Keyboard Shortcuts are requested for the current window.
Parameters | |
---|---|
data |
List : The data list to populate with shortcuts. |
menu |
Menu : The current menu, which may be null. |
deviceId |
int : The id for the connected device the shortcuts should be provided for. |
onSearchRequested
public abstract boolean onSearchRequested ()
Called when the user signals the desire to start a search.
Returns | |
---|---|
boolean |
true if search launched, false if activity refuses (blocks) |
See also:
onSearchRequested
public abstract boolean onSearchRequested (SearchEvent searchEvent)
Called when the user signals the desire to start a search.
Parameters | |
---|---|
searchEvent |
SearchEvent : A SearchEvent describing the signal to
start a search. |
Returns | |
---|---|
boolean |
true if search launched, false if activity refuses (blocks) |
onWindowAttributesChanged
public abstract void onWindowAttributesChanged (WindowManager.LayoutParams attrs)
This is called whenever the current window attributes change.
Parameters | |
---|---|
attrs |
WindowManager.LayoutParams |
onWindowFocusChanged
public abstract void onWindowFocusChanged (boolean hasFocus)
This hook is called whenever the window focus changes. See
View.onWindowFocusChangedNotLocked(boolean)
for more information.
Parameters | |
---|---|
hasFocus |
boolean : Whether the window now has focus. |
onWindowStartingActionMode
public abstract ActionMode onWindowStartingActionMode (ActionMode.Callback callback)
Called when an action mode is being started for this window. Gives the
callback an opportunity to handle the action mode in its own unique and
beautiful way. If this method returns null the system can choose a way
to present the mode or choose not to start the mode at all. This is equivalent
to onWindowStartingActionMode(android.view.ActionMode.Callback, int)
with type ActionMode#TYPE_PRIMARY
.
Parameters | |
---|---|
callback |
ActionMode.Callback : Callback to control the lifecycle of this action mode |
Returns | |
---|---|
ActionMode |
The ActionMode that was started, or null if the system should present it |
onWindowStartingActionMode
public abstract ActionMode onWindowStartingActionMode (ActionMode.Callback callback, int type)
Called when an action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all.
Parameters | |
---|---|
callback |
ActionMode.Callback : Callback to control the lifecycle of this action mode |
type |
int : One of ActionMode#TYPE_PRIMARY or ActionMode#TYPE_FLOATING . |
Returns | |
---|---|
ActionMode |
The ActionMode that was started, or null if the system should present it |