Felipe
Felipe

Reputation: 17181

How to avoid use of GPS using LocationClient of Google Play Services?

I have an app that runs in background and I want to avoid use of GPS.

According to official doc LocationRequest API:

(...) Applications cannot specify the exact location sources, such as GPS, that are used by the LocationClient. (...)

Is it really impossible to prevent the app from using GPS when using Google Play Services Fused Location Provider?

In my case, I know the Wi-Fi is always ON and it should be enough to retrieve a good position using NETWORK_PROVIDER. May I use the old-school location retriever to avoid use of GPS?

Upvotes: 0

Views: 763

Answers (1)

Paul Burke
Paul Burke

Reputation: 25584

You're looking for LocationManager, which provides much more control, but requires far more code. If you don't request ACCESS_FINE_LOCATION permission, the GPS will never be used.

Check out this guide: https://developer.android.com/guide/topics/location/strategies.html

It should be noted, if you designate ACCESS_COARSE_LOCATION with LocationRequest, it will intentionally obfuscate the location result.

Location requests from applications with ACCESS_COARSE_LOCATION and not ACCESS_FINE_LOCATION will be automatically throttled to a slower interval, and the location object will be obfuscated to only show a coarse level of accuracy.

Upvotes: 3

Related Questions