to top
Android APIs
public static class

KeyEvent.DispatcherState

extends Object
java.lang.Object
   ↳ android.view.KeyEvent.DispatcherState

Class Overview

Use with dispatch(Callback, DispatcherState, Object) for more advanced key dispatching, such as long presses.

Summary

Public Constructors

? Examples
KeyEvent.DispatcherState()
Public Methods

? Examples
void handleUpEvent( KeyEvent event)
Handle key up event to stop tracking.

? Examples
boolean isTracking( KeyEvent event)
Return true if the key event is for a key code that is currently being tracked by the dispatcher.

? Examples
void performedLongPress( KeyEvent event)
Keep track of the given event's key code as having performed an action with a long press, so no action should occur on the up.

? Examples
void reset( Object target)
Stop any tracking associated with this target.

? Examples
void reset()
Reset back to initial state.

? Examples
void startTracking( KeyEvent event, Object target)
Start tracking the key code associated with the given event.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public KeyEvent.DispatcherState ()

Added in API level 5

Public Methods

public void handleUpEvent (KeyEvent event)

Added in API level 5

Handle key up event to stop tracking. This resets the dispatcher state, and updates the key event state based on it.

This is only needed if you are directly dispatching events, rather than handling them in onKeyUp(int, KeyEvent).

public boolean isTracking (KeyEvent event)

Added in API level 5

Return true if the key event is for a key code that is currently being tracked by the dispatcher.

public void performedLongPress (KeyEvent event)

Added in API level 5

Keep track of the given event's key code as having performed an action with a long press, so no action should occur on the up.

This is only needed if you are directly dispatching events, rather than handling them in onKeyLongPress(int, KeyEvent).

public void reset (Object target)

Added in API level 5

Stop any tracking associated with this target.

public void reset ()

Added in API level 5

Reset back to initial state.

public void startTracking (KeyEvent event, Object target)

Added in API level 5

Start tracking the key code associated with the given event. This can only be called on a key down. It will allow you to see any long press associated with the key, and will result in isTracking() return true on the long press and up events.

This is only needed if you are directly dispatching events, rather than handling them in onKeyDown(int, KeyEvent).

No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.