Android的requestLocationUpdates minimumtime + minimumdistance真的不工作 [英] Android requestLocationUpdates minimumtime + minimumdistance don't really work

查看:115
本文介绍了Android的requestLocationUpdates minimumtime + minimumdistance真的不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

locationmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationlistener);

据我了解,这条线code的应该是尽可能频繁地权更新设备的位置?具体来说,每一个0miliseconds和0metres(最小)。

I understand that this line of code is supposed to update the device location as frequently as possible right? Specifically, every 0miliseconds and 0metres (minimum).

好吧,这个词'的最小'在这里是关键,但仍,为什么有时位置不更新,也许只要30多秒?我已经超时一个更新和下之间的实际时间,而在无线网络,并花了38秒即使我在code有0和0。我甚至有1000毫秒(1秒)尝试过,但仍然没有更新频繁。

Okay, the word 'minimum' is key here but still, why sometimes the location is not updated for maybe as long as 30+ seconds? I have timed the actual time between one update and the next, while on WiFi, and it took 38 seconds even though I had 0 and 0 in the code. I even tried it with 1000ms (1second) but still doesn't update as frequent.

我如何使这个更新更频繁?为什么回应这样?

How do I make this update more frequently? Why does it respond this way?

感谢您!

推荐答案

简短的回答是:你不能(使更新更频繁)

The short answer is: you can't (make it update more frequently).

文档表示你会得到更新尽可能经常如果指定MIN_DISTANCE和MIN_TIME为零。所以你看到的是尽可能经常。通常,除非事情已经改变,你不会得到更新,所以如果你不动,你不一定会得到更新。此外,由于使用的是网络位置,而不是GPS,位置精度,所以你不应该期待更新,是不是很好频繁。

The documentation indicates that you will get "updates as frequently as possible" if you specify min_distance and min_time as zero. So what you are seeing is "as frequently as possible". Usually you won't get an update unless something has changed, so if you aren't moving you won't necessarily get an update. Also, since you are using Network location and not GPS, the accuracy of locations isn't that good so you shouldn't expect updates that frequently.

此外,每个硬件厂商实现不同的位置提供者。所以更新的频率是由硬件供应商的实现决定的。

Also, each hardware vendor implements the location providers differently. So the frequency of updates is determined by the hardware vendor's implementation.

这篇关于Android的requestLocationUpdates minimumtime + minimumdistance真的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆