Android examples for android.net.wifi:Wifi State
is Wifi Active
import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; public class Main{ public static boolean isWifiActive(Context context) { Context mContext = context.getApplicationContext(); ConnectivityManager connectivity = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] info;//from ww w. j a v a 2s . c om if (connectivity != null) { info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getTypeName().equals("WIFI") && info[i].isConnected()) { return true; } } } } return false; } }