从Android上的GPS提供商处获取*粗略*位置

我的应用程序只需要非常粗略的位置数据,所以我最初将我的清单权限设置为ACCESS_COARSE_LOCATION,并为NETWORK_PROVIDER设置位置监听器.这给了我所需的粗略位置估算,但只有Google位置服务开启.

我期待如果用户只启用了GPS,我仍然可以得到他们位置的粗略估计.但似乎从GPS_PROVIDER获取任何位置信息的唯一方法是使用ACCESS_FINE_LOCATION权限.

那么,只有启用GPS,应用程序无法接收位置信息,除非它具有ACCESS_FINE_LOCATION权限吗?换句话说,如果应用只有ACCESS_COARSE_LOCATION权限,则GPS_PROVIDER无法发送粗略的位置估算值?

解决方法

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

一般来说,是的.

引用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?

引用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.

但是,我假设这不会取代LocationManager中的“将无法访问GPS”语句.我认为这意味着如果认为NETWORK_PROVIDER数据太准确,可能会被禁止.

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...