由Android 11中的设备所有者编程保存的WiFi无自动连接
我在Android 11中有一个设备所有者应用程序,该应用程序负责配置WPA WiFi网络。我在代码中所做的基本上是以下):
val config = WifiConfiguration().apply {
SSID = "\"Some-SSID\""
allowedKeyManagement.set(KeyMgmt.WPA_PSK)
preSharedKey = "\"some-password\""
this.priority = 4
status = WifiConfiguration.Status.ENABLED
hiddenSSID = false
}
val networkId = wifiManager.addNetwork(config)
wifiManager.enableNetwork(networkId, true)
成功配置WiFi网络。在设置应用程序中,我可以看到网络已保存在那里。它还说它是由我的设备所有者保存的。但是,如果设备靠近网络,则不会自动连接。作为解决方法,我目前正在使用一个每30分钟产卵的工人,如果设备未连接到WiFi,则尝试连接到已保存的配置。这个解决方法目前正在起作用,但是我希望该系统为我处理。
我在配置中缺少什么,导致我的设备未连接到那些已配置的网络?
I have a device owner app in android 11 that is responsible for configuring WPA wifi networks. What I am doing in code basically is the following):
val config = WifiConfiguration().apply {
SSID = "\"Some-SSID\""
allowedKeyManagement.set(KeyMgmt.WPA_PSK)
preSharedKey = "\"some-password\""
this.priority = 4
status = WifiConfiguration.Status.ENABLED
hiddenSSID = false
}
val networkId = wifiManager.addNetwork(config)
wifiManager.enableNetwork(networkId, true)
This successfully configures the wifi network. In the settings apps, I can see that the networks are saved there; it also says that it was saved by my device owner. However, if the device is near to the network it doesn't connect automatically. As a workaround, I am currently using a worker that spawns every 30min and if the device isn't connected to a wifi, tries to connect to the saved configurations. This workaround is working for now, but I would like the system to handle that for me.
What am I missing in my configurations that is resulting in my device not connecting to those configured networks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论