Querying the Current Connection State
If an application needs to know the connection state infrequently, it may be useful to poll for it directly. The method getConnectivityStatus() will return true if any interface is connected. If a specific interface is required, then it is possible to use isWiFiConnected(), isCellularConnected(), or getCurrentConnectivityTypes().