I want to use the ConnectivityManager
which provides the getAllNetworkInfo()
method for checking the availability of network in Android. This method wa
Try this
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
Network[] networks = cm.getAllNetworks();
if (cm != null) {
for (Network netinfo : networks) {
NetworkInfo ni = cm.getNetworkInfo(netinfo);
if (ni.isConnected() && ni.isAvailable()) {
connected = true;
}
}
}