I use android device
and I want when app start, check current network state.
so, I try this.
ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERIVCE);
NetworkInfo ethernet = manager.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET);
NetworkInfo wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (wifi.isConnected()) {
Log.d(TAG, "WIFI isConnected");
} else if (ethernet.isConnected()) {
Log.d(TAG, "Ethernet isConnected");
} else if (wifi.isAvaiable()) {
Log.d(TAG, "Wifi not connect, but wifi isAvailable");
} else {
Log.d(TAG, "not available network");
}
this source check Wi-Fi and Ethernet network state.
but when unable network. not check.
My device if use wifi, connect Wireless LAN on my device.
when disconnect Wireless Lan on my device. my source is Check wifi.isAvailable()
in conclusion,
How to check when network is not available (current source, when network is not available check wifi.isAvailable)
When connect Wireless Lan and Wifi off, check
wifi.isAvailable()
but When disconnect Wireless Lan and Wifi off , checkwifi.isAvailable()
How to distinguish from this situation.
THANKS.