Interface MagnetometerService

  • All Known Implementing Classes:
    AndroidMagnetometerService, DummyMagnetometerService, IOSMagnetometerService

    public interface MagnetometerService
    A magnetometer measures the ambient geomagnetic field for all three physical axes (x, y and z).

    The MagnetometerService provides a read-only reading property that is updated at regular intervals by the underlying platform implementation. A user of the MagnetometerService can listen to changes of the magnetic field, by registering a ChangeListener to the reading property.


     Services.get(MagnetometerService.class).ifPresent(service -> {
          MagnetometerReading reading = service.getReading();
          System.out.printf("Magnetic field: %.4f, %.4f, %.4f. Magnitude: %.4f",
                  reading.getX(), reading.getY(), reading.getZ(), reading.getMagnitude());

    Android Configuration: none

    iOS Configuration: none

    • Method Detail

      • getReading

        MagnetometerReading getReading()
        Returns a single reading from the magnetometer.
        the current magnetometer reading
      • readingProperty<MagnetometerReading> readingProperty()
        A frequently-updated reading from the magnetometer.
        A property containing a frequently-updated magnetometer reading.