Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android check location services enabled with play services location api

Tags:

You can determine if any providers are available with LocationManager, but can it be done with the google play services location api?

When nothing is enabled, in fact "access to my location" is off, all the API calls (connect(), requestLocationUpdates()) succeed, but you never get an onLocationChanged().

Seems silly to have to use both LocationManager and the LocationClient.

I guess what I need is some way to know that onLocationChanged(0 will never get called.

like image 925
user1248322 Avatar asked May 31 '13 17:05

user1248322


People also ask

What API used for finding the location services?

Google Location Services API, also known as FusedLocationProviderApi, is Google's recommended way of getting a user's location. It provides the best accuracy based on our needs.

How do you check if location services are enabled?

Settings > Location > Mode > Battery Saving . This mode only uses WiFi, Bluetooth or mobile data instead of GPS to determine the user location. That's why you have to check if the network provider is enabled and locationManager.


1 Answers

I've combed the docs and also haven't found any way to use LocationClient to detect if location services are enabled. onConnected, onDisconnected, and onConnectionFailed do not seem to be linked to whether Location Services are enabled or not.

I'm currently doing location requests using LocationClient, but using the old locationManager.isProviderEnabled(String provider) method to detect if the Location Services are enabled. This is optimal for me, as, even if LocationClient did provide a way, it makes no distinction between GPS and Network and I'd really like to be able to request that the user enable GPS.

if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {      //GPS Provider disabled     return false; } 
like image 194
Kris Pena Avatar answered Oct 20 '22 01:10

Kris Pena