Build 1.1_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
(package private)  class SensorManager.LmsFilter
           
 
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 AXIS_MINUS_X
          see remapCoordinateSystem(float[], int, int, float[])
static int AXIS_MINUS_Y
          see remapCoordinateSystem(float[], int, int, float[])
static int AXIS_MINUS_Z
          see remapCoordinateSystem(float[], int, int, float[])
static int AXIS_X
          see remapCoordinateSystem(float[], int, int, float[])
static int AXIS_Y
          see remapCoordinateSystem(float[], int, int, float[])
static int AXIS_Z
          see remapCoordinateSystem(float[], int, int, float[])
static int DATA_X
          Deprecated. 
static int DATA_Y
          Deprecated. 
static int DATA_Z
          Deprecated. 
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_NEPTUNE
           
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
(package private)  Looper mMainLooper
           
static int RAW_DATA_INDEX
          Deprecated. 
static int RAW_DATA_X
          Deprecated. 
static int RAW_DATA_Y
          Deprecated. 
static int RAW_DATA_Z
          Deprecated. 
static int SENSOR_ACCELEROMETER
          Deprecated. use Sensor instead.
static int SENSOR_ALL
          Deprecated. 
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
          Deprecated. use Sensor instead.
static int SENSOR_MAGNETIC_FIELD
          Deprecated. use Sensor instead.
static int SENSOR_MAX
          Deprecated. 
static int SENSOR_MIN
          Deprecated. 
static int SENSOR_ORIENTATION
          Deprecated. use Sensor instead.
static int SENSOR_ORIENTATION_RAW
          Deprecated. use Sensor instead.
static int SENSOR_PROXIMITY
          Deprecated. use Sensor instead.
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
          Deprecated. use Sensor instead.
static int SENSOR_TRICORDER
          Deprecated. use Sensor instead.
(package private) static SparseArray<Sensor> sHandleToSensor
           
(package private) static ArrayList<android.hardware.SensorManager.ListenerDelegate> sListeners
           
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
 Sensor getDefaultSensor(int type)
          Use this method to get the default sensor for a given type.
static float getInclination(float[] I)
          Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by getRotationMatrix(float[], float[], float[], float[]).
static float[] getOrientation(float[] R, float[] values)
          Computes the device's orientation based on the rotation matrix.
(package private) static int getRotation()
           
static boolean getRotationMatrix(float[] R, float[] I, float[] gravity, float[] geomagnetic)
          Computes the inclination matrix I as well as the rotation matrix R transforming a vector from the device coordinate system to the world's coordinate system which is defined as a direct orthonormal basis, where: X is defined as the vector product Y.Z (It is tangential to the ground at the device's current location and roughly points East). Y is tangential to the ground at the device's current location and points towards the magnetic North Pole. Z points towards the sky and is perpendicular to the ground.
 List<Sensor> getSensorList(int type)
          Use this method to get the list of available sensors of a certain type.
 int getSensors()
          Deprecated. This method is deprecated, use getSensorList(int) instead
 void onRotationChanged(int rotation)
          
 boolean registerListener(SensorEventListener listener, Sensor sensor, int rate)
          Registers a SensorEventListener for the given sensor.
 boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler)
          Registers a SensorEventListener for the given sensor.
 boolean registerListener(SensorListener listener, int sensors)
          Deprecated. This method is deprecated, use registerListener(SensorEventListener, Sensor, int) instead.
 boolean registerListener(SensorListener listener, int sensors, int rate)
          Deprecated. This method is deprecated, use registerListener(SensorEventListener, Sensor, int) instead.
static boolean remapCoordinateSystem(float[] inR, int X, int Y, float[] outR)
          Rotates the supplied rotation matrix so it is expressed in a different coordinate system.
(package private) static int sensors_data_close()
           
(package private) static int sensors_data_init()
           
(package private) static int sensors_data_open(FileDescriptor fd)
           
(package private) static int sensors_data_poll(float[] values, int[] status, long[] timestamp)
           
(package private) static int sensors_data_uninit()
           
 void unregisterListener(SensorEventListener listener)
          Unregisters a listener for all sensors.
 void unregisterListener(SensorEventListener listener, Sensor sensor)
          Unregisters a listener for the sensors with which it is registered.
 void unregisterListener(SensorListener listener)
          Deprecated. This method is deprecated, use unregisterListener(SensorEventListener) instead.
 void unregisterListener(SensorListener listener, int sensors)
          Deprecated. This method is deprecated, use unregisterListener(SensorEventListener, Sensor) instead.
 
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

@Deprecated
public static final int SENSOR_ORIENTATION
Deprecated. use Sensor instead.
A constant describing an orientation sensor. See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_ACCELEROMETER

@Deprecated
public static final int SENSOR_ACCELEROMETER
Deprecated. use Sensor instead.
A constant describing an accelerometer. See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_TEMPERATURE

@Deprecated
public static final int SENSOR_TEMPERATURE
Deprecated. use Sensor instead.
A constant describing a temperature sensor See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_MAGNETIC_FIELD

@Deprecated
public static final int SENSOR_MAGNETIC_FIELD
Deprecated. use Sensor instead.
A constant describing a magnetic sensor See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_LIGHT

@Deprecated
public static final int SENSOR_LIGHT
Deprecated. use Sensor instead.
A constant describing an ambient light sensor See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_PROXIMITY

@Deprecated
public static final int SENSOR_PROXIMITY
Deprecated. use Sensor instead.
A constant describing a proximity sensor See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_TRICORDER

@Deprecated
public static final int SENSOR_TRICORDER
Deprecated. use Sensor instead.
A constant describing a Tricorder See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_ORIENTATION_RAW

@Deprecated
public static final int SENSOR_ORIENTATION_RAW
Deprecated. use Sensor instead.
A constant describing an orientation sensor. See SensorListener for more details.

See Also:
Constant Field Values

SENSOR_ALL

@Deprecated
public static final int SENSOR_ALL
Deprecated. 
A constant that includes all sensors

See Also:
Constant Field Values

SENSOR_MIN

@Deprecated
public static final int SENSOR_MIN
Deprecated. 
Smallest sensor ID

See Also:
Constant Field Values

SENSOR_MAX

@Deprecated
public static final int SENSOR_MAX
Deprecated. 
Largest sensor ID

See Also:
Constant Field Values

DATA_X

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

See Also:
Constant Field Values

DATA_Y

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

See Also:
Constant Field Values

DATA_Z

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

See Also:
Constant Field Values

RAW_DATA_INDEX

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

See Also:
Constant Field Values

RAW_DATA_X

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

See Also:
Constant Field Values

RAW_DATA_Y

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

See Also:
Constant Field Values

RAW_DATA_Z

@Deprecated
public static final int RAW_DATA_Z
Deprecated. 
Index of the untransformed Z 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_NEPTUNE

public static final float GRAVITY_NEPTUNE
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

AXIS_X

public static final int AXIS_X
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

AXIS_Y

public static final int AXIS_Y
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

AXIS_Z

public static final int AXIS_Z
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

AXIS_MINUS_X

public static final int AXIS_MINUS_X
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

AXIS_MINUS_Y

public static final int AXIS_MINUS_Y
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

AXIS_MINUS_Z

public static final int AXIS_MINUS_Z
see remapCoordinateSystem(float[], int, int, float[])

See Also:
Constant Field Values

mMainLooper

Looper mMainLooper

sHandleToSensor

static SparseArray<Sensor> sHandleToSensor

sListeners

static final ArrayList<android.hardware.SensorManager.ListenerDelegate> sListeners
Constructor Detail

SensorManager

public SensorManager(Looper mainLooper)

Method Detail

getSensors

@Deprecated
public int getSensors()
Deprecated. This method is deprecated, use getSensorList(int) instead

Returns:
available sensors.

getSensorList

public List<Sensor> getSensorList(int type)
Use this method to get the list of available sensors of a certain type. Make multiple calls to get sensors of different types or use Sensor.TYPE_ALL to get all the sensors.

Parameters:
type - of sensors requested
Returns:
a list of sensors matching the asked type.

getDefaultSensor

public Sensor getDefaultSensor(int type)
Use this method to get the default sensor for a given type. Note that the returned sensor could be a composite sensor, and its data could be averaged or filtered. If you need to access the raw sensors use getSensorList.

Parameters:
type - of sensors requested
Returns:
the default sensors matching the asked type.

registerListener

@Deprecated
public boolean registerListener(SensorListener listener,
                                           int sensors)
Deprecated. This method is deprecated, use registerListener(SensorEventListener, Sensor, int) instead.

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

@Deprecated
public boolean registerListener(SensorListener listener,
                                           int sensors,
                                           int rate)
Deprecated. This method is deprecated, use registerListener(SensorEventListener, Sensor, int) instead.

Registers a SensorListener 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

@Deprecated
public void unregisterListener(SensorListener listener,
                                          int sensors)
Deprecated. This method is deprecated, use unregisterListener(SensorEventListener, Sensor) instead.

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

@Deprecated
public void unregisterListener(SensorListener listener)
Deprecated. This method is deprecated, use unregisterListener(SensorEventListener) instead.

Unregisters a listener for all sensors.

Parameters:
listener - a SensorListener object

unregisterListener

public void unregisterListener(SensorEventListener listener,
                               Sensor sensor)
Unregisters a listener for the sensors with which it is registered.

Parameters:
listener - a SensorEventListener object
sensor - the sensor to unregister from

unregisterListener

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

Parameters:
listener - a SensorListener object

registerListener

public boolean registerListener(SensorEventListener listener,
                                Sensor sensor,
                                int rate)
Registers a SensorEventListener for the given sensor.

Parameters:
listener - A SensorEventListener object.
sensor - The Sensor to register to.
rate - The rate sensor events are delivered at. 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.

registerListener

public boolean registerListener(SensorEventListener listener,
                                Sensor sensor,
                                int rate,
                                Handler handler)
Registers a SensorEventListener for the given sensor.

Parameters:
listener - A SensorEventListener object.
sensor - The Sensor to register to.
rate - The rate sensor events are delivered at. This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually events are received faster.
handler - The Handler the sensor events will be delivered to.
Returns:
true if the sensor is supported and successfully enabled.

getRotationMatrix

public static boolean getRotationMatrix(float[] R,
                                        float[] I,
                                        float[] gravity,
                                        float[] geomagnetic)
Computes the inclination matrix I as well as the rotation matrix R transforming a vector from the device coordinate system to the world's coordinate system which is defined as a direct orthonormal basis, where:
  • X is defined as the vector product Y.Z (It is tangential to the ground at the device's current location and roughly points East).
  • Y is tangential to the ground at the device's current location and points towards the magnetic North Pole.
  • Z points towards the sky and is perpendicular to the ground.

  • By definition:

    [0 0 g] = R * gravity (g = magnitude of gravity)

    [0 m 0] = I * R * geomagnetic (m = magnitude of geomagnetic field)

    R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points toward East, the Y axis points to the North Pole and the device is facing the sky.

    I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. The inclination angle in radians can be computed with getInclination(float[]).


    Each matrix is returned either as a 3x3 or 4x4 row-major matrix depending on the length of the passed array:

    If the array length is 16:

       /  M[ 0]   M[ 1]   M[ 2]   M[ 3]  \
       |  M[ 4]   M[ 5]   M[ 6]   M[ 7]  |
       |  M[ 8]   M[ 9]   M[10]   M[11]  |
       \  M[12]   M[13]   M[14]   M[15]  /
    
    This matrix is ready to be used by OpenGL ES's glLoadMatrixf(float[], int).

    Note that because OpenGL matrices are column-major matrices you must transpose the matrix before using it. However, since the matrix is a rotation matrix, its transpose is also its inverse, conveniently, it is often the inverse of the rotation that is needed for rendering; it can therefore be used with OpenGL ES directly.

    Also note that the returned matrices always have this form:

       /  M[ 0]   M[ 1]   M[ 2]   0  \
       |  M[ 4]   M[ 5]   M[ 6]   0  |
       |  M[ 8]   M[ 9]   M[10]   0  |
       \      0       0       0   1  /
    

    If the array length is 9:

       /  M[ 0]   M[ 1]   M[ 2]  \
       |  M[ 3]   M[ 4]   M[ 5]  |
       \  M[ 6]   M[ 7]   M[ 8]  /
    

    The inverse of each matrix can be computed easily by taking its transpose.

    The matrices returned by this function are meaningful only when the device is not free-falling and it is not close to the magnetic north. If the device is accelerating, or placed into a strong magnetic field, the returned matrices may be inaccurate.

    Parameters:
    R - is an array of 9 floats holding the rotation matrix R when this function returns. R can be null.

    I - is an array of 9 floats holding the rotation matrix I when this function returns. I can be null.

    gravity - is an array of 3 floats containing the gravity vector expressed in the device's coordinate. You can simply use the values returned by a SensorEvent of a Sensor of type TYPE_ACCELEROMETER.

    geomagnetic - is an array of 3 floats containing the geomagnetic vector expressed in the device's coordinate. You can simply use the values returned by a SensorEvent of a Sensor of type TYPE_MAGNETIC_FIELD.
    Returns:
    true on success

    false on failure (for instance, if the device is in free fall). On failure the output matrices are not modified.


    getInclination

    public static float getInclination(float[] I)
    Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by getRotationMatrix(float[], float[], float[], float[]).

    Parameters:
    I - inclination matrix see getRotationMatrix(float[], float[], float[], float[]).
    Returns:
    The geomagnetic inclination angle in radians.

    remapCoordinateSystem

    public static boolean remapCoordinateSystem(float[] inR,
                                                int X,
                                                int Y,
                                                float[] outR)
    Rotates the supplied rotation matrix so it is expressed in a different coordinate system. This is typically used when an application needs to compute the three orientation angles of the device (see getOrientation(float[], float[])) in a different coordinate system.

    When the rotation matrix is used for drawing (for instance with OpenGL ES), it usually doesn't need to be transformed by this function, unless the screen is physically rotated, such as when used in landscape mode.

    Examples:

  • Using the camera (Y axis along the camera's axis) for an augmented reality application where the rotation angles are needed :
  • remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR);

  • Using the device as a mechanical compass in landscape mode:
  • remapCoordinateSystem(inR, AXIS_Y, AXIS_MINUS_X, outR);

    Beware of the above example. This call is needed only if the device is physically used in landscape mode to calculate the rotation angles (see getOrientation(float[], float[])). If the rotation matrix is also used for rendering, it may not need to be transformed, for instance if your Activity is running in landscape mode.

    Since the resulting coordinate system is orthonormal, only two axes need to be specified.

    Parameters:
    inR - the rotation matrix to be transformed. Usually it is the matrix returned by getRotationMatrix(float[], float[], float[], float[]).
    X - defines on which world axis and direction the X axis of the device is mapped.
    Y - defines on which world axis and direction the Y axis of the device is mapped.
    outR - the transformed rotation matrix. inR and outR can be the same array, but it is not recommended for performance reason.
    Returns:
    true on success. false if the input parameters are incorrect, for instance if X and Y define the same axis. Or if inR and outR don't have the same length.

    getOrientation

    public static float[] getOrientation(float[] R,
                                         float[] values)
    Computes the device's orientation based on the rotation matrix.

    When it returns, the array values is filled with the result:

  • values[0]: azimuth, rotation around the Z axis.
  • values[1]: pitch, rotation around the X axis.
  • values[2]: roll, rotation around the Y axis.
  • Parameters:
    R - rotation matrix see getRotationMatrix(float[], float[], float[], float[]).
    values - an array of 3 floats to hold the result.
    Returns:
    The array values passed as argument.

    onRotationChanged

    public void onRotationChanged(int rotation)


    getRotation

    static int getRotation()

    sensors_data_init

    static int sensors_data_init()

    sensors_data_uninit

    static int sensors_data_uninit()

    sensors_data_open

    static int sensors_data_open(FileDescriptor fd)

    sensors_data_close

    static int sensors_data_close()

    sensors_data_poll

    static int sensors_data_poll(float[] values,
                                 int[] status,
                                 long[] timestamp)

    Build 1.1_r1 (from source)

    Please submit a feedback, bug or feature