Magnetometer data

There are two methods that you can use to have your application retrieve data from the magnetometer. You can create and register a listener, or you can poll for magnetometer data. In both cases, you create a MagnetometerSensor.Channel class that acts as the bridge between your application and the magnetometer. The data provided by the magnetometer is encapsulated in a MagnetometerData class.

The following table lists the types of information contained in a MagnetometerData object and the methods that you can use to retrieve that information.

Type of information

Methods

Time when data was captured

getTimeStamp()

Magnetometer calibration quality

getCalibrationQuality()

Magnetic field strength

getFieldStrength()

Angle between magnetic north and device axes

getDirection(), getDirectionBack(), getDirectionFront(), getDirectionLeft(), getDirectionRight(), getDirectionBottom(), getDirectionTop()

Angle between horizontal plane and magnetic field vector (dip angle)

getInclination()

OpenGL®-compatible rotation matrix that represents a rotation from world coordinates to current device orientation

getRotationMatrix()

Raw magnetometer data (µT)

getMagnetometerData()

Previous topic: Magnetometer

Was this information helpful? Send us your comments.