2017-02-26 48 views
0

阅读其他几个问题/答案后,我仍然遇到了使用wifiManager.removeNetwork工作的问题。Android - 仍然无法以编程方式删除Wifi网络

据:

Android - Cant Remove Wifi Network Programatically- The method removeNetwork(int) in the type WifiManager is not applicable for the arguments (String)

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上工作。任何人有任何想法?

回答

相关问题