I have an app that tracks the location of the device. In the past I used the Android framework location APIs. Worked as intended – so no real need to change that. But now I want to evaluate the Location Services from the Google Play Services that Google recommends to use, so I changed my app accordingly. There are some options that might come handy in the future.
For this I am following https://developer.android.com/training/location/change-location-settings.html I after resolving the quite complex dependencies and requirements I now have a working configuration. But there are issues:
Part 1
There seems to be no option to use the mode „Device only“ (meaning that only GPS is to be used for the location service and not WiFi etc. …
If I request location updates with PRIORITY_HIGH_ACCURACY, interval 10000 and smallest displacement of 20 the pending LocationSettingsResult always returns with status RESOLUTION_REQUIRED if the device is set to location mode „Device Only“. The resolution is to activate mode „High Accuracy“ which also enables WiFi etc. But in this mode location data is sent to Google which might be a privacy problem for some of my users.
I consider this a bug as the mode „Device only“ should be sufficient to fulfil the request. Where to file a bug for Google Play Services? Unfortunately those problems are out of scope for AOSP Bug Tracker and I don't know any official place to file such bugs.
Another problem arises when the location request is to be started from a service. If now the status is RESOLUTION_REQUIRED how to resolve the situation? The solution Google offers needs an activity for the resolution. But in a service there is no activity that could be used for this. The status object of the LocationSettingsResult gives access to a LocationSettingsStates object – but how to extract the cause for the problem and the possible resolution?