为什么我没有从scanResults获得SSID,我该如何获得它?

时间:2014-07-30 18:21:48

标签: android android-wifi

我正在编写代码来扫描我的android上所有可用的Wifi网络。扫描后我想显示SSID,如果网络打开/ wep / wpa / wpa2安全。我这样做的男女同志如下:

private ListView lv;
List<ScanResult> scanList;
private void getWifiNetworksList(){
        IntentFilter filter = new IntentFilter();
        filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
        final WifiManager wifiManager = (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        registerReceiver(new BroadcastReceiver() {
            @Override @SuppressLint("UseValueOf")
            public void onReceive(Context context, Intent intent){
               // sb = new StringBuilder();
                scanList = wifiManager.getScanResults();
                sb.append("\nNumber of Wifi Connections: " + scanList.size() + "\n\n");
                for(int i = 0; i < scanList.size(); i++){
                    SSIDList.add(scanList.get(i).SSID + "\n" + scanList.get(i).capabilities);
                }
                final ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.listlayout, R.id.listTextView, SSIDList);
                lv.setAdapter(adapter);                
        }, filter);
        wifiManager.startScan();
    }

但是,在我的扫描结果中,我没有获得任何SSID。我能够看到这些功能。我不知道为什么会这样。任何人都可以告诉我们出了什么问题,我该如何解决?

0 个答案:

没有答案