Package com.gluonhq.attach.connectivity
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 aChangeListener
to theconnected property
.Example
ConnectivityService.create().ifPresent(service -> { boolean connected = service.isConnected(); System.out.println("Network connectivity available? " + String.valueOf(connected)); });
Android Configuration
The permission
Note: these modifications are handled automatically by GluonFX plugin if it is used.android.permission.ACCESS_NETWORK_STATE
needs to be added.<manifest ...> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> ... </manifest>
iOS Configuration: none
- Since:
- 3.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description javafx.beans.property.ReadOnlyBooleanProperty
connectedProperty()
A read-only property indicating whether there is data connectivity available or not.static java.util.Optional<ConnectivityService>
create()
Returns an instance ofConnectivityService
.boolean
isConnected()
A boolean indicating whether there is data connectivity available or not.
-
-
-
Method Detail
-
create
static java.util.Optional<ConnectivityService> create()
Returns an instance ofConnectivityService
.- Returns:
- An instance of
ConnectivityService
.
-
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.
-
-