问题
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