InputEvent


public abstract class InputEvent
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.InputEvent
KeyEvent Object used to report key and button events. 
MotionEvent Object used to report movement (mouse, pen, finger, trackball) events. 


Common base class for input events.

Summary

Inherited constants

int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)".

Fields

public static final Creator<InputEvent> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

final InputDevice getDevice()

Gets the device that this event came from.

abstract int getDeviceId()

Gets the id for the device that this event came from.

abstract long getEventTime()

Retrieve the time this event occurred, in the SystemClock.uptimeMillis() time base.

abstract int getSource()

Gets the source of the event.

boolean isFromSource(int source)

Determines whether the event is from the given source.

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.

abstract int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

abstract void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Fields

CREATOR

Added in API level 9
public static final Creator<InputEvent> CREATOR

Public methods

describeContents

Added in API level 9
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getDevice

Added in API level 9
public final InputDevice getDevice ()

Gets the device that this event came from.

Returns
InputDevice The device, or null if unknown.

getDeviceId

Added in API level 9
public abstract int getDeviceId ()

Gets the id for the device that this event came from. An id of zero indicates that the event didn't come from a physical device and maps to the default keymap. The other numbers are arbitrary and you shouldn't depend on the values.

Returns
int The device id.

getEventTime

Added in API level 16
public abstract long getEventTime ()

Retrieve the time this event occurred, in the SystemClock.uptimeMillis() time base.

Returns
long Returns the time this event occurred, in the SystemClock.uptimeMillis() time base.

getSource

Added in API level 9
public abstract int getSource ()

Gets the source of the event.

Returns
int The event source or InputDevice.SOURCE_UNKNOWN if unknown.

isFromSource

Added in API level 18
public boolean isFromSource (int source)

Determines whether the event is from the given source.

Parameters
source int: The input source to check against. This can be a specific device type, such as InputDevice.SOURCE_TOUCH_NAVIGATION, or a more generic device class, such as InputDevice.SOURCE_CLASS_POINTER.

Returns
boolean Whether the event is from the given source.