我该如何决定使用requestLocationUpdates什么区间? [英] How do I decide what interval to use for requestLocationUpdates?
问题描述
<一个href="http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28java.lang.String,%20long,%20float,%20android.location.LocationListener%29"><$c$c>LocationManager#requestLocationUpdates$c$c>可以让你传递一个minTime和minDistance依旧参数。我有一个很难决定什么这些数字应该和可能AP preciate一些指导。
我们的应用程序是不是转由turn导航的应用程序;我只是想告诉关心的10最近点。由于我显示最近的10,就可以得到一点点陈旧,但如果用户在移动的车辆,我想/需要经常更新它们pretty的,以避免过时。
我想很多人都在模糊的要求相同的位置:我不希望数据过于陈旧,但我不想浪费电池。我怎样才能把这些含糊的要求转化为具体的数字?
***&LT;编辑&gt; ***
作为软糖的,所述标准是(minTime&安培; minDistance依旧),因此它具有
同时满足以返回一个位置。
***&LT; /编辑&gt; ***
根据您的问题
,我听起来像minTime参数是不相关的。
您真正需要担心的是minDistance依旧,因此,如果用户是在快速移动的车辆,它会保持什么。
如果一个人驾驶60英里,他们移动约27方米秒。
考虑到这一性判据......我要说的使用方法:
minTime = 60000 //每60秒更新
minDistance依旧= 90 //在快速移动的车辆,它会更新一次,大约每3秒
LocationManager#requestLocationUpdates
allows you to pass in a minTime and minDistance parameter. I'm having a hard time deciding what these numbers should be, and could appreciate some guidance.
Our app is not a turn-by-turn navigation app; I just want to show the 10 nearest points of interest. Since I'm showing the 10 nearest, they can get a little stale, but if the user is in a moving vehicle, I'd want/need to update them pretty frequently to avoid staleness.
I imagine a lot of people are in the same position of vague requirements: "I don't want the data to be too stale, but I don't want to waste battery." How can I turn these vague requirements into concrete numbers?
***<Edit>***
As of JellyBean, the criteria is (minTime & minDistance), so it has
to satisfy both to return a location.
***</Edit>***
Based on your problem, it sounds to me like the minTime parameter is irrelevant.
What you really need to worry about is minDistance, so that if a user is in a fast moving vehicle, it will keep up.
If a person is driving 60 MPH, they move about 27 meters per second.
Considering this critera... I would say to use:
minTime = 60000 // update every 60 seconds
minDistance = 90 // in a fast moving vehicle, it will update roughly once every 3 seconds
这篇关于我该如何决定使用requestLocationUpdates什么区间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!