Home » Android » android – Checking GPS status with Google Play Services

android – Checking GPS status with Google Play Services

Posted by: admin June 15, 2020 Leave a comment

Questions:

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?

How to&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.