Android Utililty Methods Wifi State Check

List of utility methods to do Wifi State Check

Description

The list of methods to do Wifi State Check are organized into topic(s).

Method

booleangetWifiState(Context context)
get Wifi State
ConnectivityManager cm = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
State wifistate = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
        .getState();
if (wifistate != State.CONNECTED) {
    return false;
State mobileState = cm.getNetworkInfo(
...
booleanisConnectedWifi(Context context)
Check if there is any connectivity to a Wifi network
NetworkInfo info = Connectivity.getNetworkInfo(context);
return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI);
booleanisConnectedWifi(Context context)
is Connected Wifi
NetworkInfo info = getNetworkInfo(context);
return isConnected(info)
        && info.getType() == ConnectivityManager.TYPE_WIFI;
booleanisWifiAvailable(Context context)
is Wifi Available
ConnectivityManager cm = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo wifiInfo = cm
        .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (wifiInfo != null && wifiInfo.isConnected()) {
    return true;
return false;
...
booleanisWifiDisabled(WifiManager wifi)
is Wifi Disabled
return wifi.getWifiState() == WifiManager.WIFI_STATE_DISABLED;
booleanisWifiDisabled(WifiManager wifi)
is Wifi Disabled
return wifi.getWifiState() == WifiManager.WIFI_STATE_DISABLED;
booleanisWifiEnabled(WifiManager wifi)
is Wifi Enabled
return wifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED;
booleanisWifiEnabled(WifiManager wifi)
is Wifi Enabled
return wifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED;
booleanisWifiEnabledOrEnabling(WifiManager wifi)
is Wifi Enabled Or Enabling
int wifiState = wifi.getWifiState();
return wifiState == WifiManager.WIFI_STATE_ENABLED
        || wifiState == WifiManager.WIFI_STATE_ENABLING;
booleanisWifiEnabledOrEnabling(WifiManager wifi)
is Wifi Enabled Or Enabling
int wifiState = wifi.getWifiState();
return wifiState == WifiManager.WIFI_STATE_ENABLED
        || wifiState == WifiManager.WIFI_STATE_ENABLING;