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


Time when data was captured


Magnetometer calibration quality


Magnetic field strength


Angle between magnetic north and device axes

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

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


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


Raw magnetometer data (µT)


Previous topic: Magnetometer

Was this information helpful? Send us your comments.