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

回答

相關問題