List of utility methods to do Network State Check
boolean | isNetworkAvailable(Context paramContext) is Network Available ConnectivityManager localConnectivityManager = (ConnectivityManager) paramContext .getSystemService(Activity.CONNECTIVITY_SERVICE); final NetworkInfo localNetworkInfo1 = localConnectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); final NetworkInfo localNetworkInfo2 = localConnectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return (localNetworkInfo1.isConnected() && localNetworkInfo2 .isConnected()); ... |
boolean | isNetworkAvailable(Context context) is Network Available ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { Log.w(LOG_TAG, "couldn't get connectivity manager"); } else { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { ... |
boolean | isNetworkRoaming(Context context) is Network Roaming ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { Log.w(LOG_TAG, "couldn't get connectivity manager"); } else { NetworkInfo info = connectivity.getActiveNetworkInfo(); if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) { ... |
boolean | isMobileDataEnable(Context context) is Mobile Data Enable ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean isMobileDataEnable = false; isMobileDataEnable = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting(); return isMobileDataEnable; |
boolean | isWifiDataEnable(Context context) is Wifi Data Enable ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean isWifiDataEnable = false; isWifiDataEnable = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting(); return isWifiDataEnable; |
boolean | isMobileConnected(Context context) is Mobile Connected if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mMobileNetworkInfo = mConnectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mMobileNetworkInfo != null) { return mMobileNetworkInfo.isAvailable() && mMobileNetworkInfo.isConnected(); ... |
boolean | isNetworkAvailable(Context context) is Network Available ConnectivityManager mgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] info = mgr.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; return false; |
boolean | isNetworkConnected(Context context) is Network Connected if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager .getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable() && mNetworkInfo.isConnected(); ... |
boolean | isMobileConnected(Context context) is Mobile Connected if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mMobileNetworkInfo = mConnectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mMobileNetworkInfo != null) { return mMobileNetworkInfo.isAvailable(); return false; |
boolean | isNetworkConnected(Context context) is Network Connected if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager .getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable(); return false; |