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
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.ReadOnlyBooleanProperty
    A read-only property indicating whether there is data connectivity available or not.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.beans.property.ReadOnlyBooleanProperty
    A read-only property indicating whether there is data connectivity available or not.
    Returns an instance of ConnectivityService.
    boolean
    A boolean indicating whether there is data connectivity available or not.
  • Property Details

    • connected

      javafx.beans.property.ReadOnlyBooleanProperty connectedProperty
      A read-only property indicating whether there is data connectivity available or not.
      See Also:
  • Method Details

    • create

      static Optional<ConnectivityService> create()
      Returns an instance of ConnectivityService.
      Returns:
      An instance of ConnectivityService.
    • connectedProperty

      javafx.beans.property.ReadOnlyBooleanProperty connectedProperty()
      A read-only property indicating whether there is data connectivity available or not.
      See Also:
    • 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.