Android LocationRequest - calling setFastestInterval with slower value than setInterval

依然范特西╮ 提交于 2019-12-11 17:31:12

问题


In Google Play Location Services, in the LocationRequest class, is there any documented behavior to what happens when you use setFastestInterval with a value slower than the one set with setInterval?

What seems to happen, according to my test in 2 different phones, is that the updates are delivered to the listener at the (slower) rate set by setFastestInterval.

However, there is an additional detail. If, for example, I call set setFastestInterval with 1 minute, but setInterval to 5 seconds, I get the updates every 1 minute, but these updates have a consistently better accuracy than if I simply set both intervals as 5 minutes (about the same high levels of accuracy as if I set both intervals to 5 seconds). This seems to indicate that, under the hood, the locations are fetched at the faster value set by setInterval, but delivered at the slower rate set by setFastestInterval.

Could anyone please confirm if this is the case and whether I can rely on this behavior?

As far as I could find, the documentation has the following to say about this situation:

If setFastestInterval(long) is set slower than setInterval(long), then your effective fastest interval is setInterval(long).

and

The system will never provide location updates faster than the minimum of getFastestInterval() and getInterval().

来源:https://stackoverflow.com/questions/55869773/android-locationrequest-calling-setfastestinterval-with-slower-value-than-seti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!