Maelig
Maelig

Reputation: 2096

Google Maps Api v2 - Detect gps activation

I want to locate user using best provider enabled. When I launch my app with GPS off, the location manager will use network to get user location.

If I turn on my GPS while the app still running, the GPS will not be used because the location manager is listening network provider.

How can I detect the activation/desactivation of GPS and update user location on the map while the location manager is using the network provider ?

SOLUTION FOUND

Use locationclient, see this code example!

Upvotes: 0

Views: 1909

Answers (2)

MaciejGórski
MaciejGórski

Reputation: 22232

Use new LocationClient fused provider. It does all the hard work for you and listens for all providers when they are enabled.

Upvotes: 1

Steve Benett
Steve Benett

Reputation: 12933

Use this line to detect if the GPS was enabled by the user:

yourLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

It will return true if it's enabled or ortherwise false.

But as MaciejGórski said, do yourself a favor and use the LocationClient. You will never ask yourself questions like this anymore.

Upvotes: 1

Related Questions