Build 1.0_r1(from source)

android.hardware
Class SensorManager

java.lang.Object
  extended by android.os.Binder
      extended by android.view.IRotationWatcher.Stub
          extended by android.hardware.SensorManager
All Implemented Interfaces:
IBinder, IInterface, IRotationWatcher

public class SensorManager
extends IRotationWatcher.Stub

Class that lets you access the device's sensors. Get an instance of this class by calling Context.getSystemService() with an argument of Context.SENSOR_SERVICE.


Nested Class Summary
 
Nested classes/interfaces inherited from interface android.view.IRotationWatcher
IRotationWatcher.Stub
 
Nested classes/interfaces inherited from interface android.os.IBinder
IBinder.DeathRecipient
 
Field Summary
static int DATA_X
          Index of the X value in the array returned by SensorListener.onSensorChanged(int, float[])
static int DATA_Y
          Index of the Y value in the array returned by SensorListener.onSensorChanged(int, float[])
static int DATA_Z
          Index of the Z value in the array returned by SensorListener.onSensorChanged(int, float[])
static float GRAVITY_DEATH_STAR_I
           
static float GRAVITY_EARTH
           
static float GRAVITY_JUPITER
           
static float GRAVITY_MARS
           
static float GRAVITY_MERCURY
           
static float GRAVITY_MOON
           
static float GRAVITY_NEPTUN
           
static float GRAVITY_PLUTO
           
static float GRAVITY_SATURN
           
static float GRAVITY_SUN
          values returned by the accelerometer in various locations in the universe.
static float GRAVITY_THE_ISLAND
           
static float GRAVITY_URANUS
           
static float GRAVITY_VENUS
           
static float LIGHT_CLOUDY
           
static float LIGHT_FULLMOON
          Various luminance values during the night (lux)
static float LIGHT_NO_MOON
           
static float LIGHT_OVERCAST
           
static float LIGHT_SHADE
           
static float LIGHT_SUNLIGHT
           
static float LIGHT_SUNLIGHT_MAX
          Various luminance values during the day (lux)
static float LIGHT_SUNRISE
           
static float MAGNETIC_FIELD_EARTH_MAX
          Maximum magnetic field on Earth's surface
static float MAGNETIC_FIELD_EARTH_MIN
          Minimum magnetic field on Earth's surface
static int RAW_DATA_INDEX
          Offset to the raw values in the array returned by SensorListener.onSensorChanged(int, float[])
static int RAW_DATA_X
          Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])
static int RAW_DATA_Y
          Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])
static int RAW_DATA_Z
          Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])
static int SENSOR_ACCELEROMETER
          A constant describing an accelerometer.
static int SENSOR_ALL
          A constant that includes all sensors
static int SENSOR_DELAY_FASTEST
          get sensor data as fast as possible
static int SENSOR_DELAY_GAME
          rate suitable for games
static int SENSOR_DELAY_NORMAL
          rate (default) suitable for screen orientation changes
static int SENSOR_DELAY_UI
          rate suitable for the user interface
static 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.
static 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.
static int SENSOR_MAX
          Largest sensor ID
static int SENSOR_MIN
          Smallest sensor ID
static int SENSOR_ORIENTATION
          A constant describing an orientation sensor.
static int SENSOR_ORIENTATION_RAW
          A constant describing an orientation sensor.
static 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)
static int SENSOR_STATUS_ACCURACY_HIGH
          This sensor is reporting data with maximum accuracy
static int SENSOR_STATUS_ACCURACY_LOW
          This sensor is reporting data with low accuracy, calibration with the environment is needed
static int SENSOR_STATUS_ACCURACY_MEDIUM
          This sensor is reporting data with an average level of accuracy, calibration with the environment may improve the readings
static int SENSOR_STATUS_UNRELIABLE
          The values returned by this sensor cannot be trusted, calibration is needed or the environment doesn't allow readings
static 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.
static 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.
static float STANDARD_GRAVITY
          Standard gravity (g) on Earth.
 
Fields inherited from interface android.os.IBinder
DUMP_TRANSACTION, FIRST_CALL_TRANSACTION, FLAG_ONEWAY, INTERFACE_TRANSACTION, LAST_CALL_TRANSACTION, PING_TRANSACTION
 
Constructor Summary
SensorManager(Looper mainLooper)
          
 
Method Summary
 int getSensors()
           
 void onRotationChanged(int rotation)
          
 boolean registerListener(SensorListener listener, int sensors)
          Registers a listener for given sensors.
 boolean registerListener(SensorListener listener, int sensors, int rate)
          Registers a listener for given sensors.
 void unregisterListener(SensorListener listener)
          Unregisters a listener for all sensors.
 void unregisterListener(SensorListener listener, int sensors)
          Unregisters a listener for the sensors with which it is registered.
 
Methods inherited from class android.view.IRotationWatcher.Stub
asBinder, asInterface, onTransact
 
Methods inherited from class android.os.Binder
attachInterface, clearCallingIdentity, dump, finalize, flushPendingCommands, getCallingPid, getCallingUid, getInterfaceDescriptor, isBinderAlive, joinThreadPool, linkToDeath, pingBinder, queryLocalInterface, restoreCallingIdentity, transact, unlinkToDeath
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SENSOR_ORIENTATION

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.

See Also:
Constant Field Values

SENSOR_ACCELEROMETER

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)

See Also:
Constant Field Values

SENSOR_TEMPERATURE

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.

See Also:
Constant Field Values

SENSOR_MAGNETIC_FIELD

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)

See Also:
Constant Field Values

SENSOR_LIGHT

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.

See Also:
Constant Field Values

SENSOR_PROXIMITY

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)

See Also:
Constant Field Values

SENSOR_TRICORDER

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.

See Also:
Constant Field Values

SENSOR_ORIENTATION_RAW

public static final int SENSOR_ORIENTATION_RAW
A constant describing an orientation sensor. Sensor values are yaw, pitch and roll Yaw is the compass heading in degrees, 0 <= range="">< 360="" 0="North," 90="East," 180="South," 270="West" this="" is="" similar="" to="" sensor_orientation="" except="" the="" data="" is="" not="" smoothed="" or="" filtered="" in="" any="" way.="">

See Also:
Constant Field Values

SENSOR_ALL

public static final int SENSOR_ALL
A constant that includes all sensors

See Also:
Constant Field Values

SENSOR_MIN

public static final int SENSOR_MIN
Smallest sensor ID

See Also:
Constant Field Values

SENSOR_MAX

public static final int SENSOR_MAX
Largest sensor ID

See Also:
Constant Field Values

DATA_X

public static final int DATA_X
Index of the X value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

DATA_Y

public static final int DATA_Y
Index of the Y value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

DATA_Z

public static final int DATA_Z
Index of the Z value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

RAW_DATA_INDEX

public static final int RAW_DATA_INDEX
Offset to the raw values in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

RAW_DATA_X

public static final int RAW_DATA_X
Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

RAW_DATA_Y

public static final int RAW_DATA_Y
Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

RAW_DATA_Z

public static final int RAW_DATA_Z
Index of the raw X value in the array returned by SensorListener.onSensorChanged(int, float[])

See Also:
Constant Field Values

STANDARD_GRAVITY

public static final float STANDARD_GRAVITY
Standard gravity (g) on Earth. This value is equivalent to 1G

See Also:
Constant Field Values

GRAVITY_SUN

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)

See Also:
Constant Field Values

GRAVITY_MERCURY

public static final float GRAVITY_MERCURY
See Also:
Constant Field Values

GRAVITY_VENUS

public static final float GRAVITY_VENUS
See Also:
Constant Field Values

GRAVITY_EARTH

public static final float GRAVITY_EARTH
See Also:
Constant Field Values

GRAVITY_MOON

public static final float GRAVITY_MOON
See Also:
Constant Field Values

GRAVITY_MARS

public static final float GRAVITY_MARS
See Also:
Constant Field Values

GRAVITY_JUPITER

public static final float GRAVITY_JUPITER
See Also:
Constant Field Values

GRAVITY_SATURN

public static final float GRAVITY_SATURN
See Also:
Constant Field Values

GRAVITY_URANUS

public static final float GRAVITY_URANUS
See Also:
Constant Field Values

GRAVITY_NEPTUN

public static final float GRAVITY_NEPTUN
See Also:
Constant Field Values

GRAVITY_PLUTO

public static final float GRAVITY_PLUTO
See Also:
Constant Field Values

GRAVITY_DEATH_STAR_I

public static final float GRAVITY_DEATH_STAR_I
See Also:
Constant Field Values

GRAVITY_THE_ISLAND

public static final float GRAVITY_THE_ISLAND
See Also:
Constant Field Values

MAGNETIC_FIELD_EARTH_MAX

public static final float MAGNETIC_FIELD_EARTH_MAX
Maximum magnetic field on Earth's surface

See Also:
Constant Field Values

MAGNETIC_FIELD_EARTH_MIN

public static final float MAGNETIC_FIELD_EARTH_MIN
Minimum magnetic field on Earth's surface

See Also:
Constant Field Values

LIGHT_SUNLIGHT_MAX

public static final float LIGHT_SUNLIGHT_MAX
Various luminance values during the day (lux)

See Also:
Constant Field Values

LIGHT_SUNLIGHT

public static final float LIGHT_SUNLIGHT
See Also:
Constant Field Values

LIGHT_SHADE

public static final float LIGHT_SHADE
See Also:
Constant Field Values

LIGHT_OVERCAST

public static final float LIGHT_OVERCAST
See Also:
Constant Field Values

LIGHT_SUNRISE

public static final float LIGHT_SUNRISE
See Also:
Constant Field Values

LIGHT_CLOUDY

public static final float LIGHT_CLOUDY
See Also:
Constant Field Values

LIGHT_FULLMOON

public static final float LIGHT_FULLMOON
Various luminance values during the night (lux)

See Also:
Constant Field Values

LIGHT_NO_MOON

public static final float LIGHT_NO_MOON
See Also:
Constant Field Values

SENSOR_DELAY_FASTEST

public static final int SENSOR_DELAY_FASTEST
get sensor data as fast as possible

See Also:
Constant Field Values

SENSOR_DELAY_GAME

public static final int SENSOR_DELAY_GAME
rate suitable for games

See Also:
Constant Field Values

SENSOR_DELAY_UI

public static final int SENSOR_DELAY_UI
rate suitable for the user interface

See Also:
Constant Field Values

SENSOR_DELAY_NORMAL

public static final int SENSOR_DELAY_NORMAL
rate (default) suitable for screen orientation changes

See Also:
Constant Field Values

SENSOR_STATUS_UNRELIABLE

public static final int SENSOR_STATUS_UNRELIABLE
The values returned by this sensor cannot be trusted, calibration is needed or the environment doesn't allow readings

See Also:
Constant Field Values

SENSOR_STATUS_ACCURACY_LOW

public static final int SENSOR_STATUS_ACCURACY_LOW
This sensor is reporting data with low accuracy, calibration with the environment is needed

See Also:
Constant Field Values

SENSOR_STATUS_ACCURACY_MEDIUM

public static final int SENSOR_STATUS_ACCURACY_MEDIUM
This sensor is reporting data with an average level of accuracy, calibration with the environment may improve the readings

See Also:
Constant Field Values

SENSOR_STATUS_ACCURACY_HIGH

public static final int SENSOR_STATUS_ACCURACY_HIGH
This sensor is reporting data with maximum accuracy

See Also:
Constant Field Values
Constructor Detail

SensorManager

public SensorManager(Looper mainLooper)

Method Detail

getSensors

public int getSensors()
Returns:
available sensors

registerListener

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

registerListener

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

unregisterListener

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

unregisterListener

public void unregisterListener(SensorListener listener)
Unregisters a listener for all sensors.

Parameters:
listener - a SensorListener object

onRotationChanged

public void onRotationChanged(int rotation)


Build 1.0_r1(from source)

Please submit a feedback, bug or feature