I was looking for a way to react a case when:
- I am connected to WiFi
- the access point has just lost internet connection (e.g the cable from router has been removed)
In such cases, Android phones or notebooks are notified about that state and showing exclamation mark next to the WiFi icon.
Is it possible to be notified about that state in Android API? I was looking in the documentation but not found any.
IMPORTANT NOTE: I am not looking for just checking internet connection manually or just listen for changing network connection status as I will not be notified when the WiFi access point that I am connected to has lost the connection.
So regarding above I was trying to just check the changes of the network connection, but as i explained it is not enough for my case:
override fun onReceive(context: Context, intent: Intent) {
val wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
DEFAULT_WIFI_STATE_VALUE)
wifiStateSubject.onNext(wifiState)
Timber.d("Current wifi state: $wifiState")
}