2010-09-29 32 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在可運行的應用程序中設置定時操作。我希望我能幫上忙。