我正在研究一种将wifi网络自动添加到android操作系统的功能。我能够做到这一切都很好:
val wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
val configuration = WifiConfiguration().apply {
SSID = "\"$name\""
preSharedKey = "\"$password\""
hiddenSSID = true
allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP)
allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP)
allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK)
allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP)
allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP)
allowedProtocols.set(WifiConfiguration.Protocol.RSN)
}
val networkId = wifiManager.addNetwork(configuration)
wifiManager.disconnect()
val enabled = wifiManager.enableNetwork(networkId, true)
wifiManager.reconnect()
但是,一个问题是当我去查看设备上的wifi管理器时,连接显示为已锁定。我无法编辑,只能删除它。
是否可以通过任何方式创建可编辑的内容,或者这是一条既硬又快的规则?