[英]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.