我正在创建一个Android应用程序,通过它的配置连接到无线网络。我按照这个How to programmatically create and read WEP/EAP WiFi configurations in Android?来连接到WEP网络,但它不起作用。当我通过Wifi设置连接时,它连接没有任何问题。从编程添加的网络分析WifiConfiguration和Wifi设置添加的WifiConfiguration不同的是他们的ip分配和代理设置:
# ProgrammaticallyAdded #
ID: 8 SSID: "quickframe" BSSID: null PRIO: 40
KeyMgmt: NONE Protocols: WPA RSN
AuthAlgorithms: OPEN SHARED
PairwiseCiphers: TKIP CCMP
GroupCiphers: WEP40 WEP104 TKIP CCMP
PSK:
eap:
phase2:
identity:
anonymous_identity:
password:
client_cert:
private_key:
ca_cert:
IP assignment: UNASSIGNED
Proxy settings: UNASSIGNED
LinkAddresses: [] Routes: [] DnsAddresses: []
# Added by Wifi Settings #
ID: 8 SSID: "quickframe" BSSID: null PRIO: 17
KeyMgmt: NONE Protocols: WPA RSN
AuthAlgorithms: OPEN SHARED
PairwiseCiphers: TKIP CCMP
GroupCiphers: WEP40 WEP104 TKIP CCMP
PSK:
eap:
phase2:
identity:
anonymous_identity:
password:
client_cert:
private_key:
ca_cert:
IP assignment: DHCP
Proxy settings: NONE
LinkAddresses: [192.168.0.89/24,] Routes: [0.0.0.0/0 -> 192.168.0.1,] DnsAddresses: [143.106.2.5,143.106.2.2,]
我还尝试通过反射添加IP分配和代理设置。但它也没有用。
ID: 8 SSID: "quickframe" BSSID: null PRIO: 0
KeyMgmt: NONE Protocols: WPA RSN
AuthAlgorithms: OPEN SHARED
PairwiseCiphers: TKIP CCMP
GroupCiphers: WEP40 WEP104 TKIP CCMP
PSK:
eap:
phase2:
identity:
anonymous_identity:
password:
client_cert:
private_key:
ca_cert:
IP assignment: DHCP
Proxy settings: NONE
LinkAddresses: [] Routes: [] DnsAddresses: []
任何人都知道如何获取IP和代理设置?我相信这些数据将使连接成为可能。
谢谢!
答案 0 :(得分:0)
实际上问题出现在我的WEP密钥中,我设置它就像我在上面提到的链接中显示的那样(How to programmatically create and read WEP/EAP WiFi configurations in Android?)。
wc.wepKeys[0] = "\"" + password + "\"";
当我删除引号时,它有效。
wc.wepKeys[0] = "" + password + "";
因此,您只需在设置SSID时使用引号。
wc.SSID = "\"" + ssid + "\"";
希望它有所帮助。
问候。