List of utility methods to do Network State Check
boolean | isNetworkAvailable(Context context) is Network Available ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { Log.i("NetWorkState", "Unavailabel"); return false; } else { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { ... |
boolean | isNetworkConnected(Context context) is Network Connected if (context != null) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); } else { return false; ... |
boolean | onNetwork(Context context) on Network final ConnectivityManager conMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { return true; } else { return false; |
boolean | haveNetworkConnection(Context context) have Network Connection boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) ... |
boolean | isNetworkConnected(Context context) Check if network exists and determine if it has Internet connectivity ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
return (ni != null && ni.isConnected());
|
boolean | isNetworkEnabled(Context context) is Network Enabled ConnectivityManager conn = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = conn.getActiveNetworkInfo();
return (info != null && info.isConnected());
|
boolean | check3GNetwork(Context context) check G Network ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { return false; } else { NetworkInfo info = connectivity.getActiveNetworkInfo(); if (info == null) { return false; ... |
Boolean | IsNetworkConnected(Context context) Is Network Connected ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] networks = manager.getAllNetworkInfo(); for (NetworkInfo network : networks) { if (network.getTypeName().equalsIgnoreCase("WIFI")) { if (network.isConnected() && network.isAvailable() && network.isConnectedOrConnecting()) { return true; ... |
boolean | isNetworkAvailableExt(Context paramContext) Check mobile network and wireless status ConnectivityManager localConnectivityManager = (ConnectivityManager) paramContext .getSystemService("connectivity"); if (localConnectivityManager == null) { return false; while (true) { NetworkInfo localNetworkInfo = localConnectivityManager .getActiveNetworkInfo(); ... |
boolean | isNetworkAvailable(Context context) Checks device for network connectivity boolean state = false; if (context != null) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { Log.i(TAG, "The device currently has data connectivity"); state = true; ... |