I'm working on an app that uses google play services. On Some phones, the client returns null for location. This happens because the locaiton option is not enabled on google setting as in the pic attached.
How to programatically check if google settings location is enabled in an android app ?
http://www.cnet.com/how-to/explaining-the-google-settings-icon-on-your-android-device/
There should be one change, where you check
TextUtils.isEmpty(locationProviders)
. It is never empty. Where there is no provider (location settings are disabled) it has value"null"
. Yes I mean value"null"
, notnull
.It's possible to check if google play services itself is available. Follow instructions here: https://developer.android.com/training/location/retrieve-current.html
It's possible getLastLocation() will return null even if Google Play Services Location Services are enabled. For instance, right after re-enabling them. However you can then take your user to the Google Play Services Location Settings by using the following intent:
Finally, it's also possible to check if Android Location Services are enabled:
I thought this is the best solution.
You can check by following code :
ACTION_LOCATION_SOURCE_SETTINGS shows the user, settings to allow configuration of current location sources.