2017-02-26 1 views
0

Après avoir lu plusieurs autres questions/réponses, j'ai toujours un problème en utilisant wifiManager.removeNetwork pour fonctionner.Android - Ne peut toujours pas supprimer le réseau Wifi par programme

Selon:

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

et

How to forget a wireless network in android programmatically?

... mon code devrait fonctionner:

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; 
    } 
} 

Cependant, quand je test sur API 23 il ne fonctionne pas. En regardant à travers le code, rien ne semble déprécié et le code fonctionne sur API 21. N'importe qui a des idées?

Répondre