我们走路时如何获得实时当前位置更新 [英] How to get real time current location update as we walk

查看:211
本文介绍了我们走路时如何获得实时当前位置更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想讨论是否有可能在我们移动时获得实时当前位置更新,我尝试使用FusedLocationProviderClient请求每2分钟更新当前位置

我们可以做些什么来实现这一点,为步行执行detectActivity并请求每2分钟或更少时间更新当前位置?

或者位于FusedLocationProviderClient上的位置更改侦听器?以便我们可以监听位置是否发生变化,并实时获取并显示在应用程序中的textview中?位置更改监听器在GoogleMap对象上可用,但现在不推荐使用,是吗?



或者我应该坚持要求更新FusedLocationProviderClient吗?



预先感谢

另外告诉我,如果我将手机从一个房间移到另一个房间,那么latlng会有变化吗? / p>

解决方案

要获取位置更新,您需要使用 LocationListener 。欲了解更多信息,请阅读Android开发者博客文章:深潜进入位置



注意:从api 23开始,您需要在运行时获取位置权限


I want to discuss if there is possibility of getting real time current location update as we move, I tried with FusedLocationProviderClient to request for current location update every 2 minutes

What can we do to achieve this, implement detectActivity for walk and request current location update every 2 minutes or less in it?

or there is on location change listener thing in FusedLocationProviderClient? so that we can listen for if there is change in location and get latlng in real time and display in textview in application? the location change listener is available on GoogleMap object but isn't recommended to use now, am I right?

or should i stick to requestupdate of FusedLocationProviderClient?

Thanks beforehand

Also tell me if i move my phone from one room to another, will there be change in latlng?

解决方案

To get location updates you need to use LocationListener. For more information read Android Developers Blog post : A Deep Dive Into Location.

NOTE: As of api 23 you need to acquire location permissions at runtime.

这篇关于我们走路时如何获得实时当前位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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