色彩时光 | 记录程序员世界的点点滴滴

wifiManager removeNetwork return false


昨日解决了android6中NoSuchFieldExecption:ipAssignment 的问题,但是指定连接wifi 在android6中仍然连接失败,调试发现wifiManager removeNetwork,addNetwork 都return false。

为啥会出现这种情况的,问题出现在android6中对wifi管理模块的改变。现在,app只能修改你自己创建的WifiConfiguration对象的状态,而不再允许修改或删除由用户或其它app创建的WifiConfiguration对象。如果想使app修改或删除其它wifiConfiguration,需要成为活跃的设备用户(Active Device Owners)

There are some changes in the Wifi Manager in Android 6.0 Any Wi-Fi configuration created by an active Device Owner can no longer be modified or deleted by the user if WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN is non-zero. The user can still create and modify their own Wi-Fi configurations. Active Device Owners have the privilege of editing or removing any Wi-Fi configurations, including those not created by them.

Please refer to this link for further details https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html

如何成为活跃设备用户:
http://stackoverflow.com/questions/21183328/how-to-make-my-app-a-device-owner

android6的重要变化:http://blog.csdn.net/w7849516230/article/details/50358907

在回到问题的解决中来,如果想控制wifiConfig 那么只能在自己的app中建立其wifiConfig。配置静态wifiConfig,遍历wifiConfig列表把配置最高的优先级给控制wifiConfig,重新连接reassociate即可


您可能也对下面文章感兴趣:

Write a Comment


* Content (required) 10~500s

分类

热门标签

友情链接