0

I am trying to code a service that repeatedly checks user location, but shuts off if certain things don't occur within about 3 minutes. I put the shut-the-service-off-logic in onLocationChanged. I just realized that if a user puts a phone on a table and leaves it there onLocationChanged may never be called, and the shutoff logic will never be entered. Is there some other method that could be overridden that gets called every time location is requested? Do I need to manually call onLocationChanged (and is that even a good idea?).

4

1 回答 1

1

创建一个CountdownTimer并将其设置millisInFuture为 3 分钟。在onFinish()定时器removeLocationUpdate中。当您启动此计时器requestLocationUpdate并在 onLocationChanged 中取消并再次启动计时器。

于 2013-04-20T01:45:42.703 回答