List of utility methods to do Network State Check
boolean | isNetworkAvailable(Context context) is Network Available ConnectivityManager conMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean availability = false; try { if (conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) .getState() == NetworkInfo.State.CONNECTED || conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .getState() == NetworkInfo.State.CONNECTED) { ... |
boolean | isNetworkAvailable(Context context) is Network Available ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager
.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
boolean | isMobileOnline(Context context) is Mobile Online ConnectivityManager conMan = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); State mobile = conMan.getNetworkInfo( ConnectivityManager.TYPE_MOBILE).getState(); if (mobile == NetworkInfo.State.CONNECTED) return true; else return false; ... |
Boolean | isInternetReachable(Context context) is Internet Reachable SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(context); Boolean ret; ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetworkInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI), dataNetworkInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); ... |
boolean | isHightBandwidthConnection(Context context) is Hight Bandwidth Connection ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
return (info != null && info.isConnected() && isConnectionFast(
info.getType(), info.getSubtype()));
|
boolean | isConnectionFast(int type, int subType) is Connection Fast if (type == ConnectivityManager.TYPE_WIFI) { return true; } else if (type == ConnectivityManager.TYPE_MOBILE) { switch (subType) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; case TelephonyManager.NETWORK_TYPE_CDMA: return false; ... |
Boolean | isNetAvailable(Context context) Checks if Network connectivity is available to download OpenCellID data try { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifiInfo != null && mobileInfo != null) { ... |
boolean | isNetworkAvailable(Context context) is Network Available try { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager .getActiveNetworkInfo(); return activeNetworkInfo != null; } catch (Exception e) { return false; |
boolean | isNetworkAvailable(Context context) is Network Available boolean netWorkStatus = false; if (null != context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { netWorkStatus = connManager.getActiveNetworkInfo() .isAvailable(); return netWorkStatus; |
boolean | isNetworkAvailable(Context context) is Network Available try { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo info = connectivity.getActiveNetworkInfo(); if (info != null && info.isConnected()) { if (info.getState() == NetworkInfo.State.CONNECTED) { return true; ... |