Our application uses Google Fused location API to receive location updates every 3 minutes. The location request settings are as follows –
- Interval –
3min
- Fastest interval –
1 min
- Priority -
PRIORITY_BALANCED_POWER_ACCURACY
In a normal running scenario, the location updates are received properly and the location accuracy is pretty good (around 20-25 m).
When the Maps application is opened, it received GPS location, and therefore our application also starts receiving location updates, which are basically from the GPS transceiver (I know this as the subsequent location updates have a speed and altitude value as well).
Problem occurs when the Maps application is now closed. Our application receives location updates, but the location coordinates do not change and every subsequent update received has a higher accuracy value. The updates may go up to even 1000m of accuracy and no accurate location are received. Opening the maps application again will make our application receive accurate and updated locations once again.
This problem can also be device specific as I saw this problem on a Motorola Moto G and not on my other Samsung or Karbonn phones.
In my experience, setting the priority to PRIORITY_BALANCED_POWER_ACCURACY
never gets positions from the GPS, unless other app is using it. That's the same behaviour that you are finding in your app (in your case you only get GPS positioning when Maps is open), and that seems to be the general behaviour (see Does PRIORITY_BALANCED_POWER_ACCURACY exclude the GPS provider?).
I haven't found any official documentation to background this so I think that it may be device-dependant. In my tests, whenever I need GPS positioning I need to change the priority to PRIORITY_HIGH_ACCURACY
.
Anyway, there is a known issue (57707) that is showing in some devices that causes the location provider to stop receiving position updates when set in PRIORITY_BALANCED_POWER_ACCURACY
until the device is restarted.
来源:https://stackoverflow.com/questions/30437144/fused-location-api-gives-highly-inaccurate-location-after-closing-google-maps