[英]Android - Still can't remove Wifi Network Programatically
After reading several other questions/answers, I'm still having an issue using wifiManager.removeNetwork to work. 阅读其他几个问题/答案后,使用wifiManager.removeNetwork仍然无法正常工作。
According to: 根据:
Android - Cant Remove Wifi Network Programatically- The method removeNetwork(int) in the type WifiManager is not applicable for the arguments (String) Android-无法以编程方式删除Wifi网络-WifiManager类型的方法removeNetwork(int)不适用于参数(字符串)
and 和
How to forget a wireless network in android programmatically? 如何以编程方式忘记android中的无线网络?
...my code should work: ...我的代码应该可以工作:
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;
}
}
However, when I test on API 23 it doesn't work. 但是,当我在API 23上进行测试时,它不起作用。 Looking through the code nothing appears depreciated and the code works on API 21. Anyone have any ideas?
仔细检查代码,似乎什么都不会贬值,并且代码可以在API 21上运行。任何人都有想法吗?
This is intended behavior. 这是预期的行为。 As of Android M apps are not allowed to modify networks that they did not create.
从Android版本开始,不允许M应用修改其未创建的网络。
See: https://code.google.com/p/android/issues/detail?id=187347 and https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-network 请参阅: https : //code.google.com/p/android/issues/detail?id=187347和https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-网络
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.