Android WifiManager getConnectionInfo requires CHANGE_WIFI_STATE?
Asked Answered
T

0

1

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.

Treillage answered 16/10, 2012 at 16:15 Comment(4)
was the user running honeycomb? Try adding <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>Ridgeling
That permission is also enabled. And this user is using 2.3.4 on Verizon with model ADR6400L.Treillage
fwiw my code works without CHANGE_WIFI_STATE, but uses ACCESS_NETWORK_STATE & ACCESS_WIFI_STATESusannahsusanne
This may help https://mcmap.net/q/1175708/-getconnectioninfo-exceptionSomatist

© 2022 - 2024 — McMap. All rights reserved.