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

booleanisWIFIAvailable(Context context)
public static boolean isWIFIAvailable(Context context)

This method will check whether WIFI is available or not , if available it will return true else it will return false
ConnectivityManager connect = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfoWifi = connect
        .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (netInfoWifi.isConnected())
    return true;
else
    return false;
...
booleanisWifiOnline(Context context)
is Wifi Online
ConnectivityManager conMan = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
        .getState();
if (wifi == NetworkInfo.State.CONNECTED)
    return true;
else
    return false;
...
booleanisWifi(Context context)
is Wifi
ConnectivityManager connectivityManager = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager
        .getActiveNetworkInfo();
if (activeNetInfo != null
        && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
    return true;
return false;
booleanisWifiEnabled(Context context)
is Wifi Enabled
ConnectivityManager mgrConn = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context
        .getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
        .getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || mgrTel
        .getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
booleanisWifiConnected(Context context)
is Wifi Connected
if (context != null) {
    ConnectivityManager mConnectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo mWiFiNetworkInfo = mConnectivityManager
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (mWiFiNetworkInfo != null) {
        return mWiFiNetworkInfo.isAvailable()
                && mWiFiNetworkInfo.isConnected();
...
booleanisWifiConnected(Context context)
is Wifi Connected
if (context != null) {
    ConnectivityManager mConnectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo mWiFiNetworkInfo = mConnectivityManager
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (mWiFiNetworkInfo != null) {
        return mWiFiNetworkInfo.isAvailable();
return false;
booleancheckWiFi(Context inContext)
check Wi Fi
WifiManager mWifiManager = (WifiManager) inContext
        .getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
int ipAddress = wifiInfo == null ? 0 : wifiInfo.getIpAddress();
if (mWifiManager.isWifiEnabled() && ipAddress != 0) {
    return true;
} else {
    return false;
...
booleanisOnWifi(Context context)
is On Wifi
WifiManager lWifiManager = (WifiManager) context
        .getSystemService(Context.WIFI_SERVICE);
return lWifiManager == null ? false : lWifiManager.isWifiEnabled()
        && lWifiManager.getConnectionInfo() != null
        && lWifiManager.getConnectionInfo().getIpAddress() != 0;
booleanwifiEnable(Context context)
wifi Enable
return NETWORK_CLASS_WIFI == getConnectedType(context);
booleanisWifi(Context mContext)
is Wifi
ConnectivityManager connectivityManager = (ConnectivityManager) mContext
        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager
        .getActiveNetworkInfo();
if (activeNetInfo != null
        && activeNetInfo.getTypeName().equals("WIFI")) {
    return true;
return false;