如何连接到受密码保护的SSID并以编程方式打开SSID而无需复制Wi-Fi网络

时间:2014-11-24 05:38:42

标签: android android-wifi

当我连接到特定的SSID时,每当我以编程方式连接到SSId时,它就会创建一个重复的网络。

这是我用来连接SSID的代码

        WifiConfiguration wifiConfiguration = new WifiConfiguration();
        wifiConfiguration.SSID="\"xsinfosol\"";
        wifiConfiguration.preSharedKey="\""+ networkPASS +"\"";
        //wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        Toast.makeText(context, "connect to::"+networkSSID, 0).show();

        int netId = wifiManager.addNetwork(wifiConfiguration);
        //wifiManager.addNetwork(wifiConfiguration);
        wifiManager.disconnect();
        wifiManager.enableNetwork(netId, true);
        wifiManager.reconnect();

请帮忙

0 个答案:

没有答案