简体   繁体   English

在android中,GPS_PROVIDER有效,但NETWORK_PROVIDER不起作用

[英]in android, GPS_PROVIDER works, but NETWORK_PROVIDER does not

I am building an android application. 我正在构建一个android应用程序。

I can get GPS coordinates fine using 我可以使用以下方法获得GPS坐标

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

But when I try to use the network provider (editing the line, not doing two registers) 但是当我尝试使用网络提供商时(编辑该行,而不做两个寄存器)

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

I get no coordinates. 我没有坐标。

I am checking if I have coordinates doing a println(location.toString()) inside the locationListener. 我正在检查是否有坐标在locationListener中执行println(location.toString())。

Both GPS and WIFI location are enabled on the device (and, as far as I can tell, other applications manage to use WIFI location) 设备上同时启用了GPS和WIFI定位(据我所知,其他应用程序设法使用WIFI定位)

Am I missing something? 我想念什么吗? Is there a special procedure to use NETWORK_PROVIDER ? 是否有使用NETWORK_PROVIDER的特殊过程? (I have only "fine location" permissions, but the docs explicitly say this also allows "coarse location") (我仅具有“精确位置”权限,但是文档明确表示这也允许“粗略位置”)

gps –> (GPS, AGPS): Name of the GPS location provider. gps –>(GPS,AGPS):GPS位置提供者的名称。 This provider determines location using satellites. 该提供商使用卫星确定位置。 Depending on conditions, this provider may take a while to return a location fix. 根据条件,此提供程序可能需要一段时间才能返回位置信息。 Requires the permission android.permission.ACCESS_FINE_LOCATION. 需要权限android.permission.ACCESS_FINE_LOCATION。

network –> (AGPS, CellID, WiFi MACID): Name of the network location provider. 网络–>(AGPS,CellID,WiFi MACID):网络位置提供商的名称。 This provider determines location based on availability of cell tower and WiFi access points. 该提供商根据蜂窝塔和WiFi接入点的可用性来确定位置。 Results are retrieved by means of a network lookup. 通过网络查找来检索结果。 Requires either of the permissions android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION. 需要权限android.permission.ACCESS_COARSE_LOCATION或android.permission.ACCESS_FINE_LOCATION。

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

相关问题 来自Android中GPS_PROVIDER或NETWORK_PROVIDER的位置不一致 - Location from GPS_PROVIDER or NETWORK_PROVIDER in android is not consistent Android:locationManager GPS_provider VS Network_provider - Android: locationManager GPS_provider VS Network_provider 如何提示用户启用GPS_PROVIDER和/或NETWORK_PROVIDER? - How to prompt user to enable GPS_PROVIDER and/or NETWORK_PROVIDER? 无法使用GPS_PROVIDER / NETWORK_PROVIDER获取用户位置 - Not getting user location using GPS_PROVIDER / NETWORK_PROVIDER 使用OnStatusChanged从GPS_PROVIDER切换到NETWORK_PROVIDER? - Using OnStatusChanged to switch to NETWORK_PROVIDER from GPS_PROVIDER? getLastKnownLocation使用GPS_PROVIDER和NETWORK_PROVIDER返回NULL - getLastKnownLocation return NULL using GPS_PROVIDER and NETWORK_PROVIDER NETWORK_PROVIDER和GPS_PROVIDER在片段中返回null - NETWORK_PROVIDER and GPS_PROVIDER returns null in fragments 使用GPS_PROVIDER和NETWORK_PROVIDER获取当前位置的问题 - Issue in getting Current Location with GPS_PROVIDER and NETWORK_PROVIDER 如何从GPS_PROVIDER自动更改为NETWORK_PROVIDER - How to change automatically from GPS_PROVIDER to NETWORK_PROVIDER 如何检查Xamarin表单中的network_provider和gps_provider? - How to check for network_provider and gps_provider in Xamarin forms?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM