Android: If both GPS & Network are requested at the same time, network provider doesn't work

北慕城南 提交于 2019-11-30 19:15:43

问题


if (gps_enabled)
    _locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);
if (network_enabled)
    _locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);

Condition:

  • You are in the building where you have wifi connection, but no GPS signal.

Result:

This works when Setting->"Use wireless networks" is on and "Use GPS satellites" is off. However, when both are checked, above code sometimes works (through network) but sometimes times out trying to get location from GPS.

I tested on nexus one.

来源:https://stackoverflow.com/questions/4455802/android-if-both-gps-network-are-requested-at-the-same-time-network-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!