NetState¶
With NetStateUtils
you can easily check some network status about your device
NetworkInfo and NetworkCapabilities
For versions below API 29, NetworkInfo will be obtained to check whether the network is available. For API 29 and above version, NetworkCapabilities will be obtained to check whether the network is available.
Check if the network is available¶
// True is available, otherwise False
val available = isNetworkAvailable()
Check if it is connected to WIFI¶
// True is in WIFI connection, otherwise False
val isWifi = isWIFI()
Check if you are on the mobile network¶
// True is in the mobile network connection, otherwise False
val isMobile = isMobile()
Check WIFI signal strength¶
// signalStrength is the signal strength
val signalStrength = getWifiDBM()