wifi的相关信息

if(WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) { 
            Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);   
            if (null != parcelableExtra) {   
                NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;  
                State state = networkInfo.getState(); 
                if(Util.isNetwork(context)){
                 WifiManager wifi_service = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
     WifiInfo wifiInfo = wifi_service.getConnectionInfo();
     List<ScanResult> scanResults= wifi_service.getScanResults();
     System.out.println("scanResults.size():"+scanResults.size());
     for(int i=0;i<scanResults.size();i++){
      ScanResult scanResult=scanResults.get(i);
      System.out.println("scanResult.SSID:"+scanResult.SSID);
      System.out.println("scanResult.BSSID:"+scanResult.BSSID);
      System.out.println("scanResult.level:"+scanResult.level);
     }
     int rssi=wifiInfo.getRssi();//getRssi() 获得802.11n
     System.out.println("网络的信号强度:"+rssi);
                }
                boolean isConnected = state==State.CONNECTED;//当然,这边可以更精确的确定状态 
                System.out.println(this.getClass().getSimpleName()+ "---isConnected"+isConnected);
            }   
        } 

你可能感兴趣的:(wifi的相关信息)