Android examples for android.net.wifi:Wifi Enable
is Wifi Enabled/Connected
import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isWifiEnabled(Context context) { boolean isWifiConnect = true; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); // check the networkInfos numbers NetworkInfo[] networkInfos = cm.getAllNetworkInfo(); for (int i = 0; i < networkInfos.length; i++) { if (networkInfos[i].getState() == NetworkInfo.State.CONNECTED) { if (networkInfos[i].getType() == ConnectivityManager.TYPE_MOBILE) { isWifiConnect = false;/*from w ww . j av a 2 s . co m*/ } if (networkInfos[i].getType() == ConnectivityManager.TYPE_WIFI) { isWifiConnect = true; } } } return isWifiConnect; } }