List of utility methods to do Network State Check
boolean | isConnected(Context context) is Connected NetworkInfo info = getNetworkInfo(context);
return isConnected(info);
|
boolean | isConnected(Context context) is Connected ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (manager.getActiveNetworkInfo() != null && manager.getActiveNetworkInfo().isAvailable() && manager.getActiveNetworkInfo().isConnected()) return true; return false; |
boolean | isConnected(Context context) Check if there is any connectivity NetworkInfo info = Connectivity.getNetworkInfo(context);
return (info != null && info.isConnected());
|
boolean | isConnected(NetworkInfo info) is Connected return info != null && info.isConnected();
|
boolean | isConnected(final Context context, final int... networkTypes) is Connected final ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (networkTypes.length > 0) for (final int networkType : networkTypes) if (ConnectivityManager.isNetworkTypeValid(networkType)) return isConnected(connectivity .getNetworkInfo(networkType)); return isConnected(connectivity.getActiveNetworkInfo()); ... |
boolean | isConnected(final NetworkInfo info) is Connected return null != info && info.isConnected();
|
boolean | isConnectedFast(Context context) Check if there is fast connectivity NetworkInfo info = Connectivity.getNetworkInfo(context);
return (info != null && info.isConnected() && Connectivity
.isConnectionFast(info.getType(), info.getSubtype()));
|
boolean | isConnectedMobile(Context context) is Connected Mobile NetworkInfo info = getNetworkInfo(context);
return isConnected(info)
&& info.getType() == ConnectivityManager.TYPE_MOBILE;
|
boolean | isConnectedMobile(Context context) Check if there is any connectivity to a mobile network NetworkInfo info = Connectivity.getNetworkInfo(context);
return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_MOBILE);
|
boolean | isConnectingToInternet() is Connecting To Internet ConnectivityManager connectivity = (ConnectivityManager) _context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) for (int i = 0; i < info.length; i++) if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; ... |