GestureEvent
public
final
class
GestureEvent
extends Object
| java.lang.Object | |
| ↳ | com.google.wear.input.GestureEvent |
Object used to report gesture input events.
A gesture input refers to an input where the user is not directly providing input on an InputDevice (like pressing a button or touching a screen). Instead, the user
performs a certain kind of gesture without directly using an input device (example: one handed
gestures using the hand on which the watch is worn) to provide input to the device.
A GestureEvent contains two important information, in addition to the time when the event happened:
- Action:: represents the abstract action/motive that is being executed by the
GestureEvent. It is intended to convey the intent of the user. Applications should
primarily use the action of a GestureEvent when deciding how to process the event. For
instance, a GestureEvent with an action of
ACTION_DISMISSshould be used to perform some form of a dismiss operation, regardless of the raw gesture that produced the GestureEvent. - Gesture:: represents the raw gesture/motion behind the GestureEvent. It shows the actual (physical) action (example, pinching). Given that different devices may use different gestures for a given gesture action, applications should not primarily rely on the gesture when deciding what to do in response to the event. Instead, the action should primarily drive the decision of how to handle the event. The gesture data may be used to instruct users on how to perform a gesture action.
Summary
Fields | |
|---|---|
public
static
final
int |
ACTION_DISMISS
The dismiss gesture action. |
public
static
final
int |
ACTION_PRIMARY
The primary gesture action. |
public
static
final
int |
GESTURE_DOUBLE_PINCH
A double pinch gesture: when a user performs quick back-to-back pinches. |
public
static
final
int |
GESTURE_UNKNOWN
Unknown gesture. |
public
static
final
int |
GESTURE_WRIST_TURN
A wrist turn gesture: when a user turns the watch-wearing wrist (example: user turns the wrist outside and back inside). |
Public constructors | |
|---|---|
GestureEvent(long eventTimeMillis, int action, int gesture)
Creates an instance of a GestureEvent. |
|
Public methods | |
|---|---|
static
String
|
actionToString(int action)
Returns a String representing a given gesture |
boolean
|
equals(Object o)
|
static
String
|
gestureToString(int gesture)
Returns a String representing a given |
int
|
getAction()
Retrieves the action for this event. |
long
|
getEventTime()
Retrieves the time this event occurred, in the |
int
|
getGesture()
Retrieves the raw gesture for this event. |
int
|
hashCode()
|
String
|
toString()
|
Inherited methods | |
|---|---|
Fields
ACTION_DISMISS
public static final int ACTION_DISMISS
The dismiss gesture action.
The action should be used to perform the dismiss action in context of the user experience. Some examples include closing a dialog, silencing or dismissing an alarm, or undoing some action.
The specific application of this action should be decided by the client of the API, in a way that its users can easily get accustomed to.
ACTION_PRIMARY
public static final int ACTION_PRIMARY
The primary gesture action.
The action should be used to perform the primary action in the context of the user experience. Some examples include answering an incoming phone call, clicking the "Send" button in a messaging application, or choosing the first (or obvious) option among a list of options.
The specific application of this action should be decided by the client of the API, in a way that its users can easily get accustomed to.
GESTURE_DOUBLE_PINCH
public static final int GESTURE_DOUBLE_PINCH
A double pinch gesture: when a user performs quick back-to-back pinches.
GESTURE_UNKNOWN
public static final int GESTURE_UNKNOWN
Unknown gesture.
This value may be used in cases where the type of gesture that produced a GestureEvent is not known. It could also be used by APIs like GestureInputManager.getGestureForAction(), as a return value for calls with an invalid
action (for example, GESTURE_UNKNOWN will be returned from GestureInputManager.getGestureForAction() if the provided action constant is not valid or
supported by the device).
GESTURE_WRIST_TURN
public static final int GESTURE_WRIST_TURN
A wrist turn gesture: when a user turns the watch-wearing wrist (example: user turns the wrist outside and back inside).
Public constructors
GestureEvent
public GestureEvent (long eventTimeMillis,
int action,
int gesture)Creates an instance of a GestureEvent.
| Parameters | |
|---|---|
eventTimeMillis |
long: the time to be reported in getEventTime(), which should be
the time the event occurred, in the SystemClock#uptimeMillis() time. |
action |
int: the gesture action for the event, to be reported in getAction().
Value is one of the following: |
gesture |
int: the gesture for the event, to be reported in getGesture().
Value is one of the following: |
| Returns | |
|---|---|
|
a GestureEvent instance with the provided parameters. |
Public methods
actionToString
public static String actionToString (int action)
Returns a String representing a given gesture action, for logging and debugging.
| Parameters | |
|---|---|
action |
int: Value is one of the following:
|
| Returns | |
|---|---|
String |
|
gestureToString
public static String gestureToString (int gesture)
Returns a String representing a given gesture, for logging and debugging.
| Parameters | |
|---|---|
gesture |
int: Value is one of the following:
|
| Returns | |
|---|---|
String |
|
getAction
public int getAction ()
Retrieves the action for this event.
| Returns | |
|---|---|
int |
Value is one of the following: |
getEventTime
public long getEventTime ()
Retrieves the time this event occurred, in the
Returns
long
getGesture
public int getGesture ()
Retrieves the raw gesture for this event.
| Returns | |
|---|---|
int |
Value is one of the following: |