LocationManager返回旧的缓存" Wifi和QUOT;与当前的时间戳位置 [英] LocationManager returns old cached "Wifi" location with current timestamp

查看:199
本文介绍了LocationManager返回旧的缓存" Wifi和QUOT;与当前的时间戳位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得当前位置。对于我实现LocationListener的,并将其注册为网络和GPS提供商:

I am trying to get the current location. For that I implement a LocationListener and register it for both the network and the GPS provider:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

I嵌段然后进行30秒,并使用该被传递到第一位置的听者的

I block then for 30 seconds and use the first location that gets passed into the listener's

onLocationChanged()

方法为100米或更高的精度。

method with an accuracy of 100 meters or better.

这其中大部分正常工作的时间。如果手机连接到某些Wifi网络,它得到正确的位置以约50米的精度只需一秒钟。如果没有WIFI,但GPS启用时,它当然可以需要一段时间才能得到一个位置。

Most of the time this works fine. If the phone is connected to some Wifi network, it takes just a second to get a correct location with an accuracy of about 50 meters. If there is no Wifi but GPS is enabled, it can of course take a while to get a location.

然而,有时,当连接到WiFi,并获取当前位置,一些旧(缓存?)previous无线的位置提供 - 这可能在15分钟到老,距离当前位置15公里。 问题是,该

Sometimes however, when connected to a Wifi and getting the current location, some old (cached?) previous "Wifi" location is provided - it might be 15 minutes old and 15 kilometers away from the current location. The problem is, that

location.getTime()

返回当前时间 - 因此,不可能知道该位置是旧

returns the current time - so it is impossible to know that the location is old.

我想我必须实现一个更复杂的解决方案 - 我只是想知道为什么这些老无线的位置有一个当前时间戳,而不是一个来自当它最初检索时间

I guess I have to implement a more elaborate solution - I would just like to know why these old "Wifi" locations have a current timestamp instead one from the time when it was originally retrieved.

推荐答案

这是有帮助的:

深入了解位置

和最后源$ C ​​$下这些传言:

and lastly the source code for that talk:

Android的protips定位

这篇关于LocationManager返回旧的缓存" Wifi和QUOT;与当前的时间戳位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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