3

Can i check if a acces points is secured with a key without connecting to it? With this i can place an icon if the wifi ap is locked or not. Many thanks, Tim

4

1 回答 1

1

使用WifiManagergetScanResults方法,并检查ScanResult的功能字段值。

    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wm.startScan();

    //some time after...

    List<ScanResult> results = wm.getScanResults();
    for( ScanResult result : results ){
        //if this ap is locked, the capabilities string should contains..
        //the name of encryption mechanism. ex> [WPA2-EAP-CCMP]
        Log.v("AP", "AP:" + result.capabilities);
    }

就我而言,结果日志如下所示......

09-16 21:01:41.308  V/AP﹕ AP:[WPA-EAP-CCMP+TKIP][WPA2-EAP-CCMP+TKIP][ESS]
09-16 21:01:41.308  V/AP﹕ AP:[WPA-PSK-CCMP][WPS][ESS]
09-16 21:01:41.308  V/AP﹕ AP:[WPA2-EAP-CCMP][ESS]
09-16 21:01:41.308  V/AP﹕ AP:[WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS]
09-16 21:01:41.308  V/AP﹕ AP:[WPA2-EAP-CCMP][ESS]
09-16 21:01:41.308  V/AP﹕ AP:[WPA2-EAP-CCMP][ESS]

您可能需要以下权限才能扫描和读取结果。

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
于 2013-09-16T12:11:23.817 回答