1

我正在为 Android 创建一个应用程序,该应用程序通过其配置连接到无线网络。我遵循了如何在 Android 中以编程方式创建和读​​取 WEP/EAP WiFi 配置?, 连接到 WEP 网络,但它不起作用。当我通过 Wifi 设置连接时,它连接没有任何问题。从以编程方式添加的网络和通过 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 和代理设置吗?我相信这些数据将使连接成为可能。

谢谢!

4

1 回答 1

0

实际上问题出在我的 WEP 密钥中,我设置它就像我提到的链接中显示的那样(如何以编程方式在 Android 中创建和读取 WEP/EAP WiFi 配置?)。

wc.wepKeys[0] = "\"" + password + "\"";

当我删除引号时,它起作用了。

wc.wepKeys[0] = "" + password + "";

所以设置SSID时只需要使用引号即可。

  wc.SSID = "\"" + ssid + "\"";

希望能帮助到你。

问候。

于 2013-04-02T20:16:59.057 回答