// The magnetometer channel will be opened with a sampling
// frequency of 10 hertz and will be active only when the app
// is in the foreground. This is the default configuration
// that would be set automatically if the no arg constructor
// for MagnetometerChannelConfig was used.
final MagnetometerChannelConfig mcc =
new MagnetometerChannelConfig(10, true, false);
// Open up the magnetometer channel for reading data and
// set this class as a MagnetometerListener.
_magnetometerChannel = MagnetometerSensor.openChannel(app, mcc);
_magnetometerChannel.addMagnetometerListener(this);