获得*粗*从Android的GPS供应商的位置 [英] Get *coarse* location from GPS provider on Android

查看:188
本文介绍了获得*粗*从Android的GPS供应商的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序只需要很粗的位置数据,所以我原本我的清单权限 ACCESS_COARSE_LOCATION ,并成立了一个位置监听器 NETWORK_PROVIDER 。这给了我正是那种粗糙的位置估计我需要的,但只有与谷歌开启定位服务。

我期待,如果用户只有启用GPS,我仍然会得到他们的位置的粗略估计。但它似乎想从任何位置信息的唯一途径 GPS_PROVIDER 是使用 ACCESS_FINE_LOCATION 的权限。

那么,难道只有GPS功能,应用程序不能接收位置信息,除非它具有 ACCESS_FINE_LOCATION 许可?换句话说,在 GPS_PROVIDER 无法发送粗略的位置估计如果应用程序只有 ACCESS_COARSE_LOCATION 许可?


解决方案

  

那么,难道只有GPS功能,应用程序不能接收位置信息,除非它有ACCESS_FINE_LOCATION许可?


一般来说,是的。

的LocationManager


  

如果您的应用程序只有粗略的许可,那么它不会有机会获得GPS或无源定位提供商。其他供应商仍然会返回定位结果,但更新率将节流和确切位置将被混淆到准确的粗略水平。


 


  

在换句话说,GPS_PROVIDER不能发送粗略的位置估计如果应用程序只有ACCESS_COARSE_LOCATION许可?


引述的Andr​​oid 4.2版本说明


  

相比于Android系统previous版本中,如果您的应用程序要求ACCESS_COARSE_LOCATION权限,但不会请求ACCESS_FINE_LOCATION允许用户定位结果可能不太准确。
  为了满足用户的隐私期望时,你的应用程序进行粗略的位置(而不是精确的位置信息)请求许可,系统将不提供用户位置估计这比一个街区更精确。


不过,我假设,这并不取代了不会有机会获得GPS从的LocationManager 语句。我认为,这意味着 NETWORK_PROVIDER 数据可能受到抑制,如果它被认为是太准确。

My app only needs very rough location data, so I originally set my manifest permissions to ACCESS_COARSE_LOCATION, and set up a location listener for NETWORK_PROVIDER. This gave me exactly the kind of rough location estimate I needed, but only with Google Location Services turned on.

I was expecting that if the user only had GPS enabled, that I would still receive a rough estimate of their location. But it seems like the only way to get ANY location information from the GPS_PROVIDER is by using the ACCESS_FINE_LOCATION permission.

So, is it true that with only GPS enabled, an app cannot receive location information unless it has the ACCESS_FINE_LOCATION permission? In other words, the GPS_PROVIDER can't send rough location estimates if the app only has ACCESS_COARSE_LOCATION permission?

解决方案

So, is it true that with only GPS enabled, an app cannot receive location information unless it has the ACCESS_FINE_LOCATION permission?

Generally speaking, yes.

Quoting the documentation for LocationManager:

If your application only has the coarse permission then it will not have access to the GPS or passive location providers. Other providers will still return location results, but the update rate will be throttled and the exact location will be obfuscated to a coarse level of accuracy.

 

In other words, the GPS_PROVIDER can't send rough location estimates if the app only has ACCESS_COARSE_LOCATION permission?

Quoting the Android 4.2 release notes:

Compared to previous versions of Android, user location results may be less accurate if your app requests the ACCESS_COARSE_LOCATION permission but does not request the ACCESS_FINE_LOCATION permission. To meet the privacy expectations of users when your app requests permission for coarse location (and not fine location), the system will not provide a user location estimate that’s more accurate than a city block.

However, I am assuming that this does not supersede the "will not have access to the GPS" statement from LocationManager. I assume that this means that NETWORK_PROVIDER data might be inhibited, if it is deemed too accurate.

这篇关于获得*粗*从Android的GPS供应商的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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