WifiConfiguration conf = new WifiConfiguration();
conf.SSID =“ ssid”;
conf.preSharedKey =“ \”密码\“”;
conf.status = WifiConfiguration.Status.ENABLED;
conf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
conf.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
int res = wifi.addNetwork(conf);
boolean b = wifi.enableNetwork(res, true);
这个wifi接入点需要用户名+密码才能连接,但是我找不到任何方法来为其设置密码。我认为这是问题所在,所以我无法成功创建它。
请帮我。非常感谢。
最佳答案
conf.wepKeys[0] = "\"password\"";
here是一个很好的例子。
关于android - 如何创建Android WifiConfiguration并使用用户名/密码访问wifi,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3139150/