0
閱讀其他幾個問題/答案後,我仍然遇到了使用wifiManager.removeNetwork工作的問題。Android - 仍然無法以編程方式刪除Wifi網絡
據:
和
How to forget a wireless network in android programmatically?
...我的代碼應該工作:
WifiManager wifiMAN = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
for (WifiConfiguration wifiCon : wifiMAN.getConfiguredNetworks()) {
if (wifiCon.SSID.equals("\""+ targetNetworkName +"\"")) {
wifiMAN.removeNetwork(wifiCon.networkId)) {
wifiMAN.saveConfiguration();
break;
}
}
然而,當我測試的API 23它不起作用。通過代碼查看沒有出現折舊,代碼在API 21上工作。任何人有任何想法?
謝謝!這很有幫助! –