The raw magnetic field values can be retrieved using this extension. You can listen for the MagneticFieldEvent for changes in the magnetic field. There are 2 important events, both indicating the magnetic field, one in the calibrated state and the other the raw uncalibrated data.
The functionality is accessed through the
There are also checks to see if the data updates are available on the current device.
This checks whether there is a magnetometer on the device and whether the particular
data updates (calibrated or uncalibrated) are available. (Uncalibrated data was only
introduced on Android v18).
Then you retrieve information in the update events:
Similarly to stop the updates call the