问题描述
在我的 android 应用程序中,只有当位置与以前的位置发生变化时,我才需要在应用程序开始时获取用户的当前 GPS 位置.但问题是当我在应用程序中时,如果位置更改(ie 如果用户在使用应用程序时正在旅行)应用程序从头开始.
In my android app I need to get current GPS location of the user at the start of the application only if location has change from the previous location. But the problem is when I inside the application if location change (ie If user was traveling while using the app) app is starting from the beginning.
获取用户当前位置后,我需要停止位置侦听器.removeUpdates 方法对我不起作用.
I need to stop location listener after getting user current location. removeUpdates method didn't work for me.
请帮助我解决这个问题.提前致谢!
Please help me on this issue.thanks in advance !
推荐答案
mLocManager.removeUpdates(locationListenerObject);
mLocManager = null;
当侦听器捕获到纬度和经度时,在您的 onLocationChange
方法中调用它.
Call this inside your onLocationChange
Method when lat and long has been captured by the listener.
希望我有所帮助..
这篇关于Android 中的停止位置侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!