NETWORK_PROVIDER不提供更新的位置 [英] NETWORK_PROVIDER not providing updated locations

查看:245
本文介绍了NETWORK_PROVIDER不提供更新的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1, this);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this);

这就是code我用听。随着GPS功能的,一切工作正常。不过,如果我关闭GPS,并依靠网络位置,它给了我陈旧的结果 - 在这种情况下,前两天。我不能让它更新。调用getLastKnownLocation返回相同的陈旧的结果。

That's the code I'm using to listen. With GPS enabled, everything works fine. However, if I disable GPS and rely on network location, it gives me stale results -- in this case, from two days ago. I cannot get it to update. Calling getLastKnownLocation returns the same stale results.

谷歌地图更新就好了,所以我知道这不是一个硬件/系统配置问题。

Google Maps updates just fine, so I know it's not a hardware/system configuration problem.

我GOOGLE了四周,发现有几个人有类似的问题,但没有答案。我已经尽我的项目定位到API级别8(2.2)以及15(4.0.3)。相同的结果。我的手机运行ICS。

I've Googled around, and found a few people with similar problems, but no answers. I've tried targeting my project to API level 8 (2.2) as well as 15 (4.0.3). Same results. My phone is running ICS.

我也试图消除对GPS_PROVIDER的要求,以及包括在getAllProviders的一切要求()。同样的协议。

I've also tried removing the request for GPS_PROVIDER, as well as including requests for everything in getAllProviders(). Same deal.

任何想法,为什么NETWORK_PROVIDER没有更新?任何帮助将大大AP preciated。

Any idea why NETWORK_PROVIDER is not updating? Any help would be greatly appreciated.

(PS不,我不,我通常用1,1我的时间/距离参数;我只是改变了它,而调试这个)

(P.S. No, I don't I normally use "1, 1" as my time/distance parameters; I just changed it while debugging this.)

编辑:我忘了提,是的,isProviderEnabled()返回true

I forgot to mention that yes, isProviderEnabled() returns true.

推荐答案

我终于找到了一种方法来解决这个问题(见的在这里我的问题)。

I finally found a way to solve this problem (see my question here).

在我的情况下,在S3银河迷你有类似的症状(无位置更新,直到重新启动...),如上述的那些。在大多数情况下位置停止更新时,该设备达到了低功耗的条件,但有时它只是发生了即使在手机完全充电。 显然,这是一个问题的地方,在 LocationManager 。我设法绕过 LocationManager 通过使用新的谷歌播放的位置服务API( LocationClient 类)。

In my case on S3 Galaxy Mini there were similar symptoms (no location updates until reboot...) like the ones described above. Location in most cases stopped updating when the device reached low power conditions, but sometimes it just happened even when the phone was fully charged. Obviously this is a problem somewhere in the LocationManager. I managed to bypass LocationManager by using the new Google Play Services API for locations (LocationClient class).

这大概就是为什么位置更新仍然在与谷歌地图,因为谷歌地图是使用谷歌播放它被公之于众之前服务API的原因。

This is probably the reason why the location updates were still working with Google Maps, because Google Maps were using Google Play Services API even before it was made public.

我建议你遵循此链接它展示了如何使用播放服务API的方式要获得使用位置代替 LocationManager 如果你遇到了这个问题。

I recommend you to follow this link which shows the way how to use Play Services API to get locations instead of using LocationManager if you encounter this problem.

林与播放服务的运行位置更新,并有绝对没有问题,像这样继续下去了 - 我一直随时接收定期位置更新

Im running location updates with Play Services and there were absolutely no problems like this anymore - I keep receiving regular location updates anytime.

谨防,这将要求用户必须拥有谷歌播放安装在他们的设备上,所以点燃之类的会出来的图片。这还需要一个最低的Andr​​oid 2.2的。

Beware that this will require that the user must have Google Play installed on their device, so Kindles and the like will be out of the picture. It also requires a minimum of Android 2.2.

这篇关于NETWORK_PROVIDER不提供更新的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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