mattm
mattm

Reputation: 5949

Is there a new way to detect Android location settings in the GooglePlayServices API?

Using the old Android location manager, you can detect whether location is enabled for GPS (and similarly for network location) using:

LocationManager x = (LocationManager) getSystemService(Activity.LOCATION_SERVICE);
boolean isGPSEnabled = x.isProviderEnabled(LocationManager.GPS_PROVIDER);

Is there a new way of doing this with the Google Play services location APIs? The documentation suggests

If you are currently using the Android framework location APIs, you are strongly encouraged to switch to the Google Play services location APIs as soon as possible.

https://developer.android.com/training/location/index.html https://developer.android.com/reference/com/google/android/gms/location/package-summary.html

Upvotes: 1

Views: 335

Answers (1)

Kazuki
Kazuki

Reputation: 1492

As Gabe commented, I think you don't have to move to new APIs (FusedLocationProviderApi) if your use case is satisfied with LocationManager. Huge downside of using FuedLocationProviderApi is that, it doesn't seem working well if you only enable network location provider.

Having said that, for original questions, if you decide to use FusedLocationProviderApi, you can use SettingsApi to confirm current user's settings for specific LocationRequest. SettingsApi also provide a means to recover from insufficient settings, i.e., it can show dialog to "enable location access" and you don't have to redirect user to settings page.

Upvotes: 1

Related Questions