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

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

概述我的应用程序只需要非常粗略的位置数据,所以我最初将我的清单权限设置为ACCESS_COARSE_LOCATION,并为NETWORK_PROVIDER设置位置监听器.这给了我所需的粗略位置估算,但只有Google位置服务开启. 我期待如果用户只启用了GPS,我仍然可以得到他们位置的粗略估计.但似乎从GPS_PROVIDER获取任何位置信息的唯一方法是使用ACCESS_FINE_LOCATION权限 我的应用程序只需要非常粗略的位置数据,所以我最初将我的清单权限设置为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上的GPS提供商处获取*粗略*位置全部内容,希望文章能够帮你解决从Android上的GPS提供商处获取*粗略*位置所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1130297.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存