2010-09-29 62 views
0

我有几个关于获取设备当前位置的问题。关于在Android中获取当前位置的问题

我相信唯一的方法就是使用requestLocationUpdates(....)

  1. 如果我订阅requestLocationUpdates ......与持续时间为1小时,如果我的电话是睡后1小时(或1小时内我重新启动我的电话),不听者仍然有效?

A.如果是 - 1小时后,当我得到位置更新,我想换时间为2小时。有没有办法做到这一点?如果不是,我可以拨打removeUpdate s,并立即拨打请求持续时间为2小时的requestLocationUpdates?

B.如果否 - 我打算设置闹钟在1小时后关闭,并在警报接收器中调用removeUpdates & requestLocationUpdates。这是正确的战略。

回答

0

我不是100%肯定,但如果重新启动您的电话服务没有再次启动,也可作为写入手册中:

minTime - the minimum time interval for notifications, in milliseconds. This field is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value. 

这仅仅是更新时间的线索,但它不是可靠。 您的做法应该是创建一个服务,该服务应使用Handler和postDelayed在可运行的应用程序中设置定时操作。我希望我能帮上忙。