Network
The Network class can be used to query the current network status by static method. Also listeners can be registered, which are fired when the network information changes.
The network status can be queried as follows:
Network.getNetworkInformation(info -> System.out.println("Current downlink: " + info.getDownlink()));
To register listeners for network state changes, you can proceed as follows:
-
Creating the Network Instance
// this ist eine View final Network network = new Network(this);
-
Registering a listener
final Registration registration = network.addNetworkInformationListener(info -> { // ...Insert printing all the network information here... });
-
This registration can be canceled later
registration.remove();
-
To resolve all registrations at once, the following method can be used:
network.clearWatch();