Added in API level 5

DispatcherState


open class DispatcherState
kotlin.Any
   ↳ android.view.KeyEvent.DispatcherState

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

Summary

Public constructors

Public methods
open Unit

Handle key up event to stop tracking.

open Boolean

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

open Unit

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.

open Unit

Reset back to initial state.

open Unit
reset(target: Any!)

Stop any tracking associated with this target.

open Unit
startTracking(event: KeyEvent!, target: Any!)

Start tracking the key code associated with the given event.

Public constructors

DispatcherState

DispatcherState()

Public methods

handleUpEvent

Added in API level 5
open fun handleUpEvent(event: KeyEvent!): Unit

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.

isTracking

Added in API level 5
open fun isTracking(event: KeyEvent!): Boolean

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

performedLongPress

Added in API level 5
open fun performedLongPress(event: KeyEvent!): Unit

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.

reset

Added in API level 5
open fun reset(): Unit

Reset back to initial state.

reset

Added in API level 5
open fun reset(target: Any!): Unit

Stop any tracking associated with this target.

startTracking

Added in API level 5
open fun startTracking(
    event: KeyEvent!,
    target: Any!
): Unit

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.