停止位置监听器在Android中 [英] Stop Location Listener in Android

查看:396
本文介绍了停止位置监听器在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我需要得到用户的当前GPS位置只有当位置已经从previous位置改变应用程序的开始。但问题是,当我在应用程序中,如果位置的变化(的若用户是在使用应用程序移动)应用程序是从头开始。

我需要获取用户当前的位置后,停止位置监听器。 removeUpdates方法并没有为我工作。

请帮我在这个问题上。 在此先感谢!

解决方案

  mLocManager.removeUpdates(locationListenerObject);
mLocManager = NULL;
 

你的 onLocationChange 方法中调用此经纬度时长已被抓获的听众。

希望我帮..

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.

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;

Call this inside your onLocationChange Method when lat and long has been captured by the listener.

Hope I helped..

这篇关于停止位置监听器在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆