public final class GestureEvent
- Object
- GestureEvent
A high level gesture detected by the framework from the motion sensor
stream and delivered to a GestureListener. The gesture detection runs in
the core so the same gestures are available on every platform that exposes
an accelerometer.
The available gestures are identified by the TYPE_* constants on this
class; register interest in one of them through
MotionSensorManager.addGestureListener(int, GestureListener).
Fields
public static final int TYPE_SHAKE = 1 | The device was shaken back and forth. |
public static final int TYPE_FLIP_FACE_DOWN = 2 | The device was turned face down (screen towards the ground). |
public static final int TYPE_FLIP_FACE_UP = 3 | The device was turned face up (screen towards the sky). |
public static final int TYPE_TILT_LEFT = 4 | The device was tilted to the left (top edge rotating towards the user’s left hand). |
public static final int TYPE_TILT_RIGHT = 5 | The device was tilted to the right. |
public static final int TYPE_TILT_FORWARD = 6 | The top of the device was tilted away from the user (pitched forward). |
public static final int TYPE_TILT_BACKWARD = 7 | The top of the device was tilted towards the user (pitched backward). |
public static final int TYPE_PICK_UP = 8 | The device was picked up from a resting position. |
public static final int TYPE_FREE_FALL = 9 | The device is in free fall (near weightlessness was detected). |
Constructors
public GestureEvent(int type, double value, long timestamp) | Creates a new gesture event. |
Methods
public int getType() | The gesture that occurred, one of the TYPE_* constants. |
public double getValue() | A magnitude describing the strength of the gesture. |
public long getTimestamp() | The time at which the gesture was detected, in milliseconds, compatible with System.currentTimeMillis(). |
public String getName() | A human readable name for the gesture type, useful for logging. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
TYPE_SHAKE
public static final int TYPE_SHAKE = 1The device was shaken back and forth.
TYPE_FLIP_FACE_DOWN
public static final int TYPE_FLIP_FACE_DOWN = 2The device was turned face down (screen towards the ground).
TYPE_FLIP_FACE_UP
public static final int TYPE_FLIP_FACE_UP = 3The device was turned face up (screen towards the sky).
TYPE_TILT_LEFT
public static final int TYPE_TILT_LEFT = 4The device was tilted to the left (top edge rotating towards the user’s
left hand).
TYPE_TILT_RIGHT
public static final int TYPE_TILT_RIGHT = 5The device was tilted to the right.
TYPE_TILT_FORWARD
public static final int TYPE_TILT_FORWARD = 6The top of the device was tilted away from the user (pitched forward).
TYPE_TILT_BACKWARD
public static final int TYPE_TILT_BACKWARD = 7The top of the device was tilted towards the user (pitched backward).
TYPE_PICK_UP
public static final int TYPE_PICK_UP = 8The device was picked up from a resting position.
TYPE_FREE_FALL
public static final int TYPE_FREE_FALL = 9The device is in free fall (near weightlessness was detected).
Constructor details
GestureEvent
public GestureEvent(int type, double value, long timestamp)Creates a new gesture event. Application code does not normally
construct these; they are delivered by the framework.
Parameters
typeint- one of the
TYPE_*constants valuedouble- a magnitude describing the gesture; the peak acceleration in
meters per second squared for
TYPE_SHAKE,TYPE_PICK_UPandTYPE_FREE_FALL, or the tilt angle in radians for the tilt and flip gestures timestamplong- the event time in milliseconds
Method details
getType
public int getType()The gesture that occurred, one of the
TYPE_* constants.getValue
public double getValue()A magnitude describing the strength of the gesture. See the constructor
documentation for the meaning per gesture type.
getTimestamp
public long getTimestamp()The time at which the gesture was detected, in milliseconds, compatible
with
System.currentTimeMillis().getName
public String getName()A human readable name for the gesture type, useful for logging.
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())