getLastKnownLocation VS requestLocationUpdates [英] getLastKnownLocation vs requestLocationUpdates

查看:362
本文介绍了getLastKnownLocation VS requestLocationUpdates的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Andr​​oid应用程序发送最新鲜和最精确的定位到服务器的每5分钟。

I want to send the most fresh and accurate location from my android app to the server every 5 min.

在此<一个href=\"http://stackoverflow.com/questions/22279059/how-to-notify-the-server-every-5-minutes-on-users-location\">question有人建议我创建一个alarmManager这将注册LocationUpdates。

In this question I was advised to create an alarmManager which will register to LocationUpdates.

为什么这不仅仅是打电话getLastKnownLocation更好

Why is this better than just calling getLastKnownLocation

和检查其准确性?

推荐答案

getLastKnownLocation会给你从网络供应商的最后的位置锁定。它可能不会给出确切的当前位置(见谷歌文档)
LocationUpdates,另一方面,将给予的当前位置。
你可以使用locationClient实现它。当位置改变时,OnLocationChanged(位置L)方法被调用它会为您提供最新的位置。您还可以设置后位置更新的时间。

getLastKnownLocation will give you the last location fix from the network provider. It may not give the exact current location (see google documentation) LocationUpdates, on the other hand, will give the current location. you can implement it using locationClient. When the location is changed, OnLocationChanged(Location l) method is called which will provide you with most recent location. you can also set time after which location is updated.

这篇关于getLastKnownLocation VS requestLocationUpdates的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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