public interface ConnectivityService
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
Services.get(ConnectivityService.class).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
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyBooleanProperty |
connected
A read-only property indicating whether there is data connectivity available or not.
|
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.ReadOnlyBooleanProperty |
connectedProperty()
A read-only property indicating whether there is data connectivity available or not.
|
boolean |
isConnected()
A boolean indicating whether there is data connectivity available or not.
|
javafx.beans.property.ReadOnlyBooleanProperty connectedProperty
isConnected()
javafx.beans.property.ReadOnlyBooleanProperty connectedProperty()
isConnected()
boolean isConnected()