java.lang.Object | |
↳ | android.hardware.SensorEvent |
This class represents a sensor event and holds informations such as the sensor type (eg: accelerometer, orientation, etc...), the time-stamp, accuracy and of course the sensor's data.
Definition of the coordinate system used by the SensorEvent API.
The coordinate space is defined relative to the screen of the phone in its default orientation. The axes are not swapped when the device's screen orientation changes. The OpenGL ES coordinate system is used. The origin is in the lower-left corner with respect to the screen, with the X axis horizontal and pointing right, the Y axis vertical and pointing up and the Z axis pointing outside the front face of the screen. In this system, coordinates behind the screen have negative Z values. Note: This coordinate system is different from the one used in the Android 2D APIs where the origin is in the top-left corner. x<0 x>0 ^ | +-----------+--> y>0 | | | | | | | | / z<0 | | / | | / O-----------+/ |[] [ ] []/ +----------/+ y<0 / / |/ z>0 (toward the sky) O: Origin (x=0,y=0,z=0)
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
accuracy | The accuracy of this event. | ||||||||||
sensor | The sensor that generated this event. | ||||||||||
timestamp | The time in nanosecond at which the event happened | ||||||||||
values | The length and contents of the values array vary depending on which
sensor type is being monitored (see also SensorEvent for a
definition of the coordinate system used):
All values are angles in degrees. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
The accuracy of this event. See SensorManager for details.
The sensor that generated this event. See SensorManager for details.
The time in nanosecond at which the event happened
The length and contents of the values array vary depending on which sensor type is being monitored (see also SensorEvent for a definition of the coordinate system used):
All values are angles in degrees.
values[0]: Azimuth, angle between the magnetic north direction and the Y axis, around the Z axis (0 to 359). 0=North, 90=East, 180=South, 270=West
values[1]: Pitch, rotation around X axis (-180 to 180), with positive values when the z-axis moves toward the y-axis.
values[2]: Roll, rotation around Y axis (-90 to 90), with positive values when the x-axis moves away from the z-axis.
Note: This definition is different from yaw, pitch and roll used in aviation where the X axis is along the long side of the plane (tail to nose).
Note: It is preferable to use getRotationMatrix() in conjunction with remapCoordinateSystem() and getOrientation() to compute these values; while it may be more expensive, it is usually more accurate.
All values are in SI units (m/s^2) and measure the acceleration applied to the phone minus the force of gravity.
values[0]: Acceleration minus Gx on the x-axis
values[1]: Acceleration minus Gy on the y-axis
values[2]: Acceleration minus Gz on the z-axis
Examples:
All values are in micro-Tesla (uT) and measure the ambient magnetic field in the X, Y and Z axis.