Friday 29 January 2021

How can I prevent WifiManager.getConnectionInfo from triggering a location check?

When my app has location permissions on Android and I want to get the IP of the phone, calling WifiManager.getConnectionInfo is triggering a location event on AppOpsManager. Since Google says my app is using the location in the background, I think this is one of the reasons why. My app needs the IP of the phone for communication with other devices and it starts getting that information on Application.onCreate(). I can probably move the code to get the ip to be called later (not onCreate), but it isn't a simple task, will probably involve a serious rewrite.

I do have other ways of getting the IP but given the variety of devices out there, this is one of the more reliable ways.

Is there a solution for this issue?

Edit: This issue just became a bigger problem for me because a third party library I require apparently makes a called to WifiManager after the app goes on the background as well.



from How can I prevent WifiManager.getConnectionInfo from triggering a location check?

No comments:

Post a Comment