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 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.
<manifest ...>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
...
</manifest>
iOS Configuration: none
- Since:
- 3.0.0
-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ReadOnlyBooleanProperty
A read-only property indicating whether there is data connectivity available or not. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyBooleanProperty
A read-only property indicating whether there is data connectivity available or not.static Optional<ConnectivityService>
create()
Returns an instance ofConnectivityService
.boolean
A boolean indicating whether there is data connectivity available or not.
-
Property Details
-
connected
javafx.beans.property.ReadOnlyBooleanProperty connectedPropertyA read-only property indicating whether there is data connectivity available or not.- See Also:
-
-
Method Details
-
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.- 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.
-