android.hardware.SensorManager
Summary
Constants
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
float
GRAVITY_DEATH_STAR_I
Constant Value:
3.5303614E-7
public
static
final
float
GRAVITY_EARTH
public
static
final
float
GRAVITY_JUPITER
public
static
final
float
GRAVITY_MARS
public
static
final
float
GRAVITY_MERCURY
public
static
final
float
GRAVITY_MOON
public
static
final
float
GRAVITY_NEPTUN
public
static
final
float
GRAVITY_PLUTO
public
static
final
float
GRAVITY_SATURN
public
static
final
float
GRAVITY_SUN
values returned by the accelerometer in various locations in the universe.
all values are in SI units (m/s^2)
Constant Value:
275.0
public
static
final
float
GRAVITY_THE_ISLAND
public
static
final
float
GRAVITY_URANUS
public
static
final
float
GRAVITY_VENUS
public
static
final
float
LIGHT_CLOUDY
public
static
final
float
LIGHT_FULLMOON
Various luminance values during the night (lux)
Constant Value:
0.25
public
static
final
float
LIGHT_NO_MOON
public
static
final
float
LIGHT_OVERCAST
public
static
final
float
LIGHT_SHADE
public
static
final
float
LIGHT_SUNLIGHT
public
static
final
float
LIGHT_SUNLIGHT_MAX
Various luminance values during the day (lux)
Constant Value:
120000.0
public
static
final
float
LIGHT_SUNRISE
public
static
final
float
MAGNETIC_FIELD_EARTH_MAX
Maximum magnetic field on Earth's surface
Constant Value:
60.0
public
static
final
float
MAGNETIC_FIELD_EARTH_MIN
Minimum magnetic field on Earth's surface
Constant Value:
30.0
public
static
final
int
SENSOR_ACCELEROMETER
A constant describing an accelerometer.
Sensor values are acceleration in the X, Y and Z axis,
where the X axis has positive direction toward the right side of the device,
the Y axis has positive direction toward the top of the device
and the Z axis has positive direction toward the front of the device.
The direction of the force of gravity is indicated by acceleration values in the
X, Y and Z axes. The typical case where the device is flat relative to the surface
of the Earth appears as -STANDARD_GRAVITY in the Z axis
and X and Z values close to zero.
Acceleration values are given in SI units (m/s^2)
Constant Value:
2
(0x00000002)
public
static
final
int
SENSOR_ALL
A constant that includes all sensors
Constant Value:
127
(0x0000007f)
public
static
final
int
SENSOR_DELAY_FASTEST
get sensor data as fast as possible
Constant Value:
0
(0x00000000)
public
static
final
int
SENSOR_DELAY_GAME
rate suitable for games
Constant Value:
1
(0x00000001)
public
static
final
int
SENSOR_DELAY_NORMAL
rate (default) suitable for screen orientation changes
Constant Value:
3
(0x00000003)
public
static
final
int
SENSOR_DELAY_UI
rate suitable for the user interface
Constant Value:
2
(0x00000002)
public
static
final
int
SENSOR_LIGHT
A constant describing an ambient light sensor
Only the first value is defined for this sensor and it contains
the ambient light measure in lux.
Constant Value:
16
(0x00000010)
public
static
final
int
SENSOR_MAGNETIC_FIELD
A constant describing a magnetic sensor
Sensor values are the magnetic vector in the X, Y and Z axis,
where the X axis has positive direction toward the right side of the device,
the Y axis has positive direction toward the top of the device
and the Z axis has positive direction toward the front of the device.
Magnetic values are given in micro-Tesla (uT)
Constant Value:
8
(0x00000008)
public
static
final
int
SENSOR_MAX
Largest sensor ID
Constant Value:
64
(0x00000040)
public
static
final
int
SENSOR_MIN
Smallest sensor ID
Constant Value:
1
(0x00000001)
public
static
final
int
SENSOR_ORIENTATION
A constant describing an orientation sensor.
Sensor values are yaw, pitch and roll
Yaw is the compass heading in degrees, range [0, 360[
0 = North, 90 = East, 180 = South, 270 = West
Pitch indicates the tilt of the top of the device,
with range -90 to 90.
Positive values indicate that the bottom of the device is tilted up
and negative values indicate the top of the device is tilted up.
Roll indicates the side to side tilt of the device,
with range -90 to 90.
Positive values indicate that the left side of the device is tilted up
and negative values indicate the right side of the device is tilted up.
Constant Value:
1
(0x00000001)
public
static
final
int
SENSOR_PROXIMITY
A constant describing a proximity sensor
Only the first value is defined for this sensor and it contains
the distance between the sensor and the object in meters (m)
Constant Value:
32
(0x00000020)
public
static
final
int
SENSOR_TEMPERATURE
A constant describing a temperature sensor
Only the first value is defined for this sensor and it
contains the ambient temperature in degree C.
Constant Value:
4
(0x00000004)
public
static
final
int
SENSOR_TRICORDER
A constant describing a Tricorder
When this sensor is available and enabled, the device can be
used as a fully functional Tricorder. All values are returned in
SI units.
Constant Value:
64
(0x00000040)
public
static
final
float
STANDARD_GRAVITY
Standard gravity (g) on Earth. This value is equivalent to 1G
Constant Value:
9.80665
Public Methods
public
static
void
mapSensorDataToWindow(int sensor, float[] values, int orientation)
Helper function to convert the specified sensor's data to the windows's
coordinate space from the device's coordinate space.
This is relevant only when the window is not oriented to the natural
screen's orientation.
This helper is useful when the sensor data is to be used to display
graphical elements; for example in the case of the acceleration sensor
an application may want to consider that the Y axis always points "up"
with respect to the window's UI.
This mapping is meaningful only for acceleration, orientation and magnetic
sensors and in a certain way to the application itself.
Parameters
orientation
| the orientation of the window the sensors data is to be used with
only acceptable values are 0 (natural orientation, usually portrait) and 90
(rotated window, usually landscape).
|
public
boolean
registerListener(SensorListener listener, int sensors)
Registers a listener for given sensors.
Parameters
listener
| sensor listener object |
sensors
| a bit masks of the sensors to register to |
Returns
- true if the sensor is supported and successfully enabled
public
boolean
registerListener(SensorListener listener, int sensors, int rate)
Registers a listener for given sensors.
Parameters
listener
| sensor listener object |
sensors
| a bit masks of the sensors to register to |
rate
| rate of events. This is only a hint to the system. events
may be received faster or slower than the specified rate. Usually events
are received faster. |
Returns
- true if the sensor is supported and successfully enabled
public
void
unregisterListener(SensorListener listener, int sensors)
Unregisters a listener for the sensors with which it is registered.
Parameters
listener
| a SensorListener object |
sensors
| a bit masks of the sensors to unregister from
|
public
void
unregisterListener(SensorListener listener)
Unregisters a listener for all sensors.
Parameters
listener
| a SensorListener object
|