简体   繁体   English

Android 4.1.1中的NETWORK_PROVIDER行为是否已更改?

[英]Has NETWORK_PROVIDER behavior changed in Android 4.1.1?

I have an existing well-tested app that utilizes the GPS_PROVIDER and NETWORK_PROVIDER with the same LocationListener . 我有一个经过良好测试的应用程序,它使用带有相同LocationListenerGPS_PROVIDERNETWORK_PROVIDER

LocationManager reports gps, network, and passive location providers are available and enabled. LocationManager报告gps,网络和被动位置提供程序可用并已启用。

I have recently upgraded my Galaxy Nexus to 4.1.1 and now the NETWORK_PROVIDER does not deliver any location changes. 我最近将Galaxy Nexus升级到4.1.1,现在NETWORK_PROVIDER没有提供任何位置更改。 Testing with an Galaxy S III running 4.0.4 works as I am accustomed to, with network location updates coming through, even if WiFi is turned off. 使用运行4.0.4的Galaxy S III进行测试就像我习惯的那样,即使WiFi关闭,网络位置更新也会通过。 When WiFi is turned off, I get the cell tower position. 当WiFi关闭时,我得到了手机信号塔的位置。

Talking with colleagues here, I can't rule out some kind of coincidental hardware failure or some sort of default setting change that I haven't found. 在这里与同事交谈,我不能排除某种巧合的硬件故障或某些我没有找到的默认设置更改。 I've double checked throughout the settings and it appears that everything is properly set. 我在整个设置中进行了双重检查,看起来一切都已正确设置。

WiFi is on, Cell network is on, GPS is on, network services are all enabled. WiFi已打开,Cell网络已开启,GPS已开启,网络服务均已启用。 I have no GPS signal at my desk, so it's easy to notice when the network location fails to provide a result. 我的办公桌上没有GPS信号,所以当网络位置无法提供结果时很容易注意到。

Anyone else running into similar issues with Verizon Galaxy Nexus + 4.1.1, or 4.1.1 and any phone? 还有其他人遇到与Verizon Galaxy Nexus + 4.1.1或4.1.1以及任何手机类似的问题吗?

As an additional wrinkle, Google Maps is finding my location, but my PASSIVE_PROVIDER is not generating a location either. 作为额外的皱纹,谷歌地图找到我的位置,但我的PASSIVE_PROVIDER也没有生成位置。

The behavior of Android has not changed with regard to the NETWORK_PROVIDER . 关于NETWORK_PROVIDER ,Android的行为没有改变。

I don't know what went wrong or why, but I removed/replaced the battery and SIM card on my Galaxy Nexus and the network provider seems to be providing the correct results. 我不知道出了什么问题或者为什么,但我删除/更换了Galaxy Nexus上的电池和SIM卡,网络提供商似乎提供了正确的结果。

The lesson for me? 给我的教训? Do not assume you will ever get a location reported to your listener, even if you are certain that the network provider is available, enabled and connected. 即使您确定网络提供商可用,已启用并已连接,也不要假设您将向听众报告位置。

In my case, I'll need to add another check to make sure my LocationListener does not keep running if I do not get any locations reported. 在我的情况下,如果我没有报告任何位置,我将需要添加另一个检查以确保我的LocationListener不会继续运行。

I have read someone's supposition about this problem. 我已经读过某人关于这个问题的假设。 It is "In some devices if there is no update after request then a network provider do not give a callback". 它是“在某些设备中,如果请求后没有更新,则网络提供商不会给出回叫”。

Consider that possibility. 考虑这种可能性。

In my case, I use a getLastKnownLocation() before starting a current location tracking. 在我的例子中,我在开始当前位置跟踪之前使用了getLastKnownLocation() Try ctrl + f getLastKnownLocation in this article . 本文中尝试ctrl + f getLastKnownLocation

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

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