Android WifiManager getConnectionInfo requires CHANGE_WIFI_STATE?

扶醉桌前 提交于 2019-12-11 06:28:55

问题


I'm getting a user report on an error about missing the CHANGE_WIFI_STATE permission:

Error:

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) 

This is the code block:

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

I thought this only required ACCESS_WIFI_STATE, since I'm not doing any enabling/disabling of wifi? Haven't been able to replicate in testing.

来源:https://stackoverflow.com/questions/12919052/android-wifimanager-getconnectioninfo-requires-change-wifi-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!