Added in API level 5

KeyEvent.DispatcherState


public static class KeyEvent.DispatcherState
extends Object

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


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

Summary

Public constructors

DispatcherState()

Public methods

void handleUpEvent(KeyEvent event)

Handle key up event to stop tracking.

boolean isTracking(KeyEvent event)

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

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.

void reset(Object target)

Stop any tracking associated with this target.

void reset()

Reset back to initial state.

void startTracking(KeyEvent event, Object target)

Start tracking the key code associated with the given event.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

DispatcherState

public DispatcherState ()

Public methods

handleUpEvent

Added in API level 5
public void handleUpEvent (KeyEvent event)

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 Callback.onKeyUp.

Parameters
event KeyEvent

isTracking

Added in API level 5
public boolean isTracking (KeyEvent event)

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

Parameters
event KeyEvent

Returns
boolean

performedLongPress

Added in API level 5
public 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.

This is only needed if you are directly dispatching events, rather than handling them in Callback.onKeyLongPress.

Parameters
event KeyEvent

reset

Added in API level 5
public void reset (Object target)

Stop any tracking associated with this target.

Parameters
target Object

reset

Added in API level 5
public void reset ()

Reset back to initial state.

startTracking

Added in API level 5
public void startTracking (KeyEvent event, 
                Object target)

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 KeyEvent.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 Callback.onKeyDown.

Parameters
event KeyEvent

target Object