Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking GPS status with Google Play Services

Google recommends now using Google Play Services to manage user location. But how can we, using this API, check wether GPS is turned on in device or if we still have gps connection?

In com.google.android.gms.location.LocationListener we have only one method abstract void onLocationChanged(Location location) which is called when the location has changed, but we don't know there anything about GPS status.

How to use Google Play Services like "old" LocationManager and LocationListener?

like image 999
Kamil Lelonek Avatar asked Jun 15 '13 08:06

Kamil Lelonek


1 Answers

But how can we, using this API, check wether GPS is turned on in device or if we still have gps connection?

You can't, AFAICT. I suppose the argument is that since LocationClient is blending data from several sources, there is no API to determine if any specific source is or is not being used.

You will need to use LocationManager if you want to determine whether GPS is enabled or not.

like image 107
CommonsWare Avatar answered Sep 30 '22 06:09

CommonsWare