Android的WifiManager getConnectionInfo需要CHANGE_WIFI

2019-10-17 07:18发布

我收到关于失踪的CHANGE_WIFI_STATE权限的错误用户报告:

错误:

java.lang.SecurityException: WifiService: Neither user 10137 nor current process has android.permission.CHANGE_WIFI_STATE.
    at android.net.wifi.WifiManager.getConnectionInfo(WifiManager.java:642) 

这是代码块:

WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifiMan != null) {
    WifiInfo wifiInfo = wifiMan.getConnectionInfo();

我认为这只是所需ACCESS_WIFI_STATE,因为我没有做无线网络的任何启用/禁用? 一直没能在测试中进行复制。

文章来源: Android WifiManager getConnectionInfo requires CHANGE_WIFI_STATE?