Android的位置每30秒更新 [英] Android Location Update every 30 seconds

查看:127
本文介绍了Android的位置每30秒更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我确定手机是活性通过读取加速度计,我想更新每30秒的电话的位置。如果一段时间后,我决定就没有动力,我停止位置更新。

If I determine the phone is active by reading the accelerometer, I want to update the location of the phone every 30 seconds. If after a while, I determine it's not moving, I stop the location updates.

它是更好地留下一个LocationListener的那段时间,或者是它更好地注册一个LocationListener的每30秒,得到的最新情况,并注销?

Is it better to leave a LocationListener on during that time, or is it better to register a LocationListener every 30 seconds, get an update, and unregister?

对于这两种方法,我想了一会儿后超时,如果我不能得到一个位置更新。我想知道哪种方法是既获得一致的更新和电池续航时间方面比较好。

For both methods, I would timeout after a while if I can't get a location update. I want to know which method is better in terms of both getting consistent updates and battery life.

和我正在试图通过GPS卫星的更新,而不是网络,尽管我知道网络是速度更快,更少的电池消耗,但我需要通过卫星得到它。请记住这一点。

And I'm trying to get updates through GPS satellites, not network, even though I know network is faster and less battery consuming, but I need to get it through satellites. Please keep that in mind.

推荐答案

恕我直言,30秒快速获得听众,获得更新和关闭它背下来。唯一的例外可能是,如果你愿意接受一个非常大的数字的准确性。如果你真的需要它每隔30秒,离开它活跃,但电池受到影响。

IMHO, 30 seconds is to fast to get the listener, get an update, and shut it back down. The only exception to that may be if you are willing to accept a very large accuracy number. If you really need it every 30 seconds, leave it active, but the battery suffers.

这篇关于Android的位置每30秒更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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