I have a method to detect connection status
boolean isInternetAvailable(WebView view) {
Boolean connected = false;
try {
ConnectivityManager connectivityManager = (ConnectivityManager) view.getContext()
.getSystemService(view.getContext().CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
connected = networkInfo != null && networkInfo.isAvailable() &&
networkInfo.isConnected();
Log.d("available", Boolean.toString(networkInfo.isAvailable()));
Log.d("connected", Boolean.toString(networkInfo.isConnected()));
Log.d("compare", Boolean.toString(networkInfo.getState() == NetworkInfo.State.CONNECTED));
return connected;
} catch (Exception e) {
}
return connected;
}
but when i disconnect all internet cables from my computer, and i can't load any page actually, emulator still thinks what he is connected and returns
11-21 13:43:22.103 20824-20824/lt.example.app D/available: true
11-21 13:43:22.103 20824-20824/lt.example.app D/connected: true
11-21 13:43:22.103 20824-20824/lt.example.app D/compare: true
to console, this method used in WebViewClient to detect connection while using WebView, what can be ?