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.

    Example

     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

    Since:
    3.0.0
    • Method Detail

      • getReading

        MagnetometerReading getReading()
        Returns a single reading from the magnetometer.
        Returns:
        the current magnetometer reading
      • readingProperty

        javafx.beans.property.ReadOnlyObjectProperty<MagnetometerReading> readingProperty()
        A frequently-updated reading from the magnetometer.
        Returns:
        A property containing a frequently-updated magnetometer reading.