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:

  1. Creating the Network Instance

    // this is a view
    final Network network = new Network(this);
  2. Registering a listener

    final Registration registration = network.addNetworkInformationListener(info -> {
      // ...Insert printing all the network information here...
  3. This registration can be canceled later

  4. To resolve all registrations at once, the following method can be used: