gpt4 book ai didi

android - 以编程方式连接到 Android 中的 WPA/WPA2 PSK

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:56 24 4
gpt4 key购买 nike

尝试以编程方式从 Android 连接到我的无线网络。

安全类型是WPA2,加密AES。

这没有按预期工作:

private WifiConfiguration saveWepConfig(String password, String networkSSID) {
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";
// conf.wepKeys[0] = "\"" + password + "\"";
conf.preSharedKey = "\"" + password + "\"";
conf.wepTxKeyIndex = 0;
conf.hiddenSSID = true;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
return conf;
}

我必须在这里加密密码吗?只保存连接,不连接。

最佳答案

啊...我发布问题后立即找到了解决方案:

    WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";
conf.preSharedKey = "\"" + password + "\"";
// conf.hiddenSSID = true;
// conf.wepTxKeyIndex = 0;
// conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
// conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

conf.status = WifiConfiguration.Status.ENABLED;
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

它对我有用。谢谢。

关于android - 以编程方式连接到 Android 中的 WPA/WPA2 PSK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19747668/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com