Interface AccelerometerService

  • All Known Implementing Classes:
    AndroidAccelerometerService, DummyAccelerometerService, IOSAccelerometerService

    public interface AccelerometerService
    An accelerometer measures the acceleration force that is applied to a device in all three physical axes (x, y and z).

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

    Example

     AccelerometerService.create().ifPresent(service -> {
          Acceleration acceleration = service.getCurrentAcceleration();
          System.out.printf("Current acceleration: %.2f, %.2f, %.2f",
                  acceleration.getX(), acceleration.getY(), acceleration.getZ());
      });

    Android Configuration: none

    iOS Configuration: none

    Since:
    3.0.0
    • Method Detail

      • getCurrentAcceleration

        Acceleration getCurrentAcceleration()
        Returns a single reading from the accelerometer.
        Returns:
        the current accelerometer reading
      • accelerationProperty

        javafx.beans.property.ReadOnlyObjectProperty<Acceleration> accelerationProperty()
        A frequently-updated reading from the accelerometer.
        Returns:
        A property containing a frequently-updated accelerometer reading.