Android获取WIFI状态

WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);

 if(wifiManager != null){

      int wifiState = wifiManager.getWifiState();

 }

WIFI有四种状态,getWifiState()会返回四种状态码,分别是:

       1. wifiManager.WIFI_STATE_DISABLED (1)

  2. wifiManager..WIFI_STATE_ENABLED (3)

  3. wifiManager..WIFI_STATE_DISABLING (0)

  4 wifiManager..WIFI_STATE_ENABLING  (2)

你可能感兴趣的:(Android获取WIFI状态)