繁体   English   中英

定位服务的`getLastKnownLocation()`是否检查手机的当前GPS位置?

[英]Does Location Services' `getLastKnownLocation()` check phone's current GPS location?

一些资源说getLastKnownLocation()仅给出了某个先前应用的位置更改监听器的位置。

但是对话中我缺少一件事-如果手机启用了GPS,随着手机移动,这不是GPS跟踪/更新吗? 因此,如果我调用getLastKnownLocation() ,是不是从手机不断更新的GPS获取当前的GPS?

如果是这样,那为什么人们要警告不要使用它/指责它可能获得“陈旧”的位置? 如果正在跟踪/更新GPS,并且getLastKnownLocation()一次性获取了它的当前位置,是什么使getLastKnownLocation()变坏了?

我对Locations服务或GPS有什么误解?

文档说: Returns a Location indicating the data from the last known location fix obtained from the given provider.

另外,关于“过期位置”: This can be done without starting the provider. Note that this location could be out-of-date, for example if the device was turned off and moved to another location. This can be done without starting the provider. Note that this location could be out-of-date, for example if the device was turned off and moved to another location. (“此”是指获得最后一个已知位置)。

另外,摘自LocationProvider docsEach provider has a set of criteria under which it may be used; for example, some providers require GPS hardware and visibility to a number of satellites; others require the use of the cellular radio, or access to a specific carrier's network, or to the internet. They may also have different battery consumption characteristics or monetary costs to the user. Each provider has a set of criteria under which it may be used; for example, some providers require GPS hardware and visibility to a number of satellites; others require the use of the cellular radio, or access to a specific carrier's network, or to the internet. They may also have different battery consumption characteristics or monetary costs to the user.

如果手机启用了GPS,那么手机移动时GPS不会跟踪/更新吗?

是的,但是不是一直。 这与电池消耗有关,如果手机不断更新GPS位置,电池寿命将受到很大影响。 GPS位置通常在某些应用程序请求时进行更新。 但是,即使该请求也不能保证成功。 例如,假设您要进入隧道。 某些应用程序要求在进入隧道之前立即更新GPS坐标,然后它会成功。 现在,您已经进入了5公里长的隧道。 您的设备很可能无法从隧道中获取GPS定位,因此在接下来的5公里(至少)内, getLastKnownLocation()将返回过时的值, 因为设备的最后一个已知位置位于隧道的入口

您可以做的是明确请求更新GPS位置,但是这可能需要一些时间,并且不能保证会成功。

您假设“如果手机启用了GPS,那么手机移动时GPS不会跟踪/更新”。 这个假设是不正确的。 GPS功能会占用大量电池电量,因此应谨慎使用,并且几乎可以肯定并非所有时间都可以使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM