如何确保我停止了locationManager requestUpdates?

问题描述 投票:1回答:1

我正在寻找我当前位置的位置,但只有一次,我不能使用requestSingleUpdate,因为它需要在低于2.3的Android版本上运行。我通过TimerTask调用它,当我得到位置时,我停止timer.cancel()。如何确保我停止了locationManager requestUpdates? (我调用了locationManager.removeUpdates,但有没有其他方法可以监控请求)

android android-location
1个回答
3
投票

如果你调用timer.cancel,locationupdatelistener继续工作。你只能使用locationManager.removeUpdates,这是100%安全的,停止更新

© www.soinside.com 2019 - 2024. All rights reserved.