Here you can find the source of getWifiState(Context context)
public static boolean getWifiState(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo.State; public class Main { public static boolean getWifiState(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); State wifistate = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .getState();/*from ww w . j a v a2 s. c o m*/ if (wifistate != State.CONNECTED) { return false; } State mobileState = cm.getNetworkInfo( ConnectivityManager.TYPE_MOBILE).getState(); boolean ret = State.CONNECTED != mobileState; return ret; } }