Most visited

Recently visited

Added in API level 9

InputEvent

public abstract class InputEvent
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.InputEvent
Known Direct Subclasses


输入事件的通用基类。

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<InputEvent> CREATOR

Public methods

int describeContents()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。

final InputDevice getDevice()

获取此事件来自的设备。

abstract int getDeviceId()

获取此事件来自的设备的ID。

abstract long getEventTime()

检索此事件发生的时间,在 uptimeMillis()时基中。

abstract int getSource()

获取事件的来源。

boolean isFromSource(int source)

确定事件是否来自给定源。

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

CREATOR

Added in API level 9
Creator<InputEvent> CREATOR

Public methods

describeContents

Added in API level 1
int describeContents ()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getDevice

Added in API level 9
InputDevice getDevice ()

获取此事件来自的设备。

Returns
InputDevice The device, or null if unknown.

getDeviceId

Added in API level 9
int getDeviceId ()

获取此事件来自的设备的ID。 ID为0表示事件不是来自物理设备,而是映射到默认键盘映射。 其他数字是任意的,你不应该依赖于这些值。

Returns
int The device id.

也可以看看:

getEventTime

Added in API level 16
long getEventTime ()

检索此事件发生的时间,在 uptimeMillis()时基中。

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

getSource

Added in API level 9
int getSource ()

获取事件的来源。

Returns
int The event source or SOURCE_UNKNOWN if unknown.

也可以看看:

isFromSource

Added in API level 18
boolean isFromSource (int source)

确定事件是否来自给定源。

Parameters
source int: The input source to check against. This can be a specific device type, such as SOURCE_TOUCH_NAVIGATION, or a more generic device class, such as SOURCE_CLASS_POINTER.
Returns
boolean Whether the event is from the given source.

Hooray!