2010-06-29 141 views
1

WifiConfiguration conf = new WifiConfiguration(); conf.SSID =“ssid”; conf.preSharedKey =“\”密码\“”; conf.status = WifiConfiguration.Status.ENABLED;如何创建Android Wifi配置并使用用户名/密码访问wifi

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接入点需要用户名+密码连接到,但我找不到任何方式将密码设置为它。我认为这是问题,所以我不能成功创建它。

请帮我解决这个问题。非常感谢。

回答