1 year ago
#352834
Ankit Koirala
Wifi saved programatically by device owner in android 11 doesn't connect automatically
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?
android
android-wifi
android-11
wifimanager
0 Answers
Your Answer