Android Wifi State Check isConnectedWifi(Context context)

Here you can find the source of isConnectedWifi(Context context)

Description

is Connected Wifi

Declaration

public static boolean isConnectedWifi(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isConnectedWifi(Context context) {
        NetworkInfo info = getNetworkInfo(context);
        return isConnected(info)
                && info.getType() == ConnectivityManager.TYPE_WIFI;
    }/*from w  ww.  jav  a2s . co m*/

    public static NetworkInfo getNetworkInfo(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo();
    }

    public static boolean isConnected(Context context) {
        NetworkInfo info = getNetworkInfo(context);
        return isConnected(info);
    }

    public static boolean isConnected(NetworkInfo info) {
        return info != null && info.isConnected();
    }
}

Related

  1. getWifiState(Context context)
  2. isConnectedWifi(Context context)
  3. isWifiAvailable(Context context)
  4. isWifiDisabled(WifiManager wifi)
  5. isWifiDisabled(WifiManager wifi)
  6. isWifiEnabled(WifiManager wifi)