Interface ConnectivityService

  • All Known Implementing Classes:
    AndroidConnectivityService, DummyConnectivityService, IOSConnectivityService

    public interface ConnectivityService
    The connectivity service can be used to determine whether the device is currently connected to a network or not. The connectivity can be to any networking service, i.e. WiFi, cell phone data, etc.

    The ConnectivityService provides a read-only connected property that is updated whenever the network connectivity of the device changes. A user of the ConnectivityService can listen to changes of the network connectivity, by registering a ChangeListener to the connected property.

    Example

     ConnectivityService.create().ifPresent(service -> {
          boolean connected = service.isConnected();
          System.out.println("Network connectivity available? " + String.valueOf(connected));
      });

    Android Configuration

    The permission android.permission.ACCESS_NETWORK_STATE needs to be added.

    Note: these modifications are handled automatically by GluonFX plugin if it is used.
     <manifest ...>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        ...
      </manifest>

    iOS Configuration: none

    Since:
    3.0.0
    • Method Detail

      • connectedProperty

        javafx.beans.property.ReadOnlyBooleanProperty connectedProperty()
        A read-only property indicating whether there is data connectivity available or not.
        Returns:
        Property will be true if there is data connectivity, and false otherwise.
      • isConnected

        boolean isConnected()
        A boolean indicating whether there is data connectivity available or not.
        Returns:
        Will be true if there is data connectivity, and false otherwise.