requestLocationUpdates minTime参数目的 [英] requestLocationUpdates minTime parameter purpose
问题描述
我创建它记录用户的位置,每30分钟,并允许用户在地图上查看所有位置的应用程序(教育目的)。我不想更新为超过30分钟更频繁,但它们是
这是我怎么称呼 requestLocationUpdates
:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,30 * 60 * 1000,0,PE);
现在,该文件明确指出:
位置更新之间所经历的时间绝不会低于minTime
块引用>不过,我在这里看到这样的声明不同的一些答案(这个答案,例如)。
这似乎是我得到时,他们都可以从GPS的更新。该GPS图标永远不会熄灭,更新速度变得大于1更新/秒。所以,我有2个问题在这里:
- 的
minTime
参数不履行其目的,甚至还不如一个提示(是的,一个提示到30分钟更新率导致超过更新第二.. )。它有什么作用呢?- 是否有任何其他方式做到这一点?我不希望GPS启用所有的时间,因为它会消耗我的电池太快。也许我可以安排警报重复每次30分钟,并调用
requestSingleUpdate
解决方案
该minTime参数不符合其目的,甚至还不如一个提示(是的,一个提示到30分钟更新率导致超过更新第二...)。它有什么作用呢?
块引用>从杰利贝恩起设备必须遵守
minTime
参数,所以它确实有一个目的(现在的)。
有没有其他办法做到这一点?我不希望GPS启用所有的时间,因为它会消耗我的电池太快。也许我可以安排警报重复每次30分钟,并调用requestSingleUpdate?
块引用>是,使用一个处理程序来请求与一个更新
requestSingleUpdate()
每次30分钟。我在一个 previous问题之前解决这一点,让我知道,如果code在这个问题的答案可以帮助,如果您有任何问题,它并没有解决。
I'm creating an application (For educational purposes) which records the user's location every 30 minutes, and enables the user the view all the locations on the map. I don't want updates to be more frequent than 30 minutes, but they are.
This is how I call
requestLocationUpdates
:locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 60 * 1000, 0, pe);
Now, the documentation clearly says:
The elapsed time between location updates will never be less than minTime
But I did see some answers here on SO stating differently (This answer, for example).
It seems like I'm getting updates whenever they are available from the GPS. The GPS icon never turns off and the updates rate becomes greater than 1 update/second. So I have 2 questions here:
- The
minTime
parameter doesn't fulfill its purpose, not even as a hint (Yea, a hint to 30 minutes update rate leads to more than update a second...). What does it do, then?- Is there any other way to do it? I don't want the GPS to be enabled all the time because it will consume my battery too fast. Maybe I could schedule alarms repeating each 30 minutes, and call
requestSingleUpdate
?
解决方案The minTime parameter doesn't fulfill its purpose, not even as a hint (Yea, a hint to 30 minutes update rate leads to more than update a second...). What does it do, then?
From Jellybean onwards devices must observe the
minTime
parameter, so it does have a purpose (now).Is there any other way to do it? I don't want the GPS to be enabled all the time because it will consume my battery too fast. Maybe I could schedule alarms repeating each 30 minutes, and call requestSingleUpdate?
Yes, use a Handler to request one update with
requestSingleUpdate()
every 30 minutes.I've tackled this before in a previous question, let me know if the code in that answer helps and if you have any questions it doesn't address.
这篇关于requestLocationUpdates minTime参数目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!