我正在构建一个显示可用网络的示例应用程序,然后提示用户选择网络并在连接前询问wifi密码并发送该密码进行Wi-Fi身份验证。我的问题是如何为wi发送该密码-fi身份验证。 感谢
答案 0 :(得分:0)
明确回答你的问题:
How do I connect to a specific Wi-Fi network in Android programmatically?
但是,这将适合你..你知道SSID 解决方案看起来像这样:
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
WifiManager wifiManager = (WifiManager).getSystemService(WIFI_SERVICE);
//remember id
int netId = wifiManager.addNetwork(wifiConfig);
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
wifiManager.reconnect();