GPS 提供商是否需要 ACCESS_FINE_LOCATION 权限?

发布于 2025-01-11 17:56:59 字数 801 浏览 0 评论 0原文

这个 SO 线程似乎表明它确实如此,但链接同一线程中的 文档 说:

除非另有说明,所有位置 API 方法都需要 Manifest.permission.ACCESS_COARSE_LOCATION 或 Manifest.permission.ACCESS_FINE_LOCATION 权限。如果您的应用程序仅具有粗略权限,则提供商仍将返回位置结果,但确切位置将被混淆为粗略精度。

这让我觉得 Google 为 GPS 提供商添加了粗略位置支持。但是,我收到此错误:

Caused by: java.lang.SecurityException: "gps" location provider require ACCESS_FINE_LOCATION permission.

当然,最好的方法是使用 融合位置提供程序 API 但在那之前我认为文档应该对此更清楚?主要是寻找更新的答案。

This SO thread seems to indicate that it does but the links to documentation in the same thread says:

Unless otherwise noted, all Location API methods require the Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION permissions. If your application only has the coarse permission then providers will still return location results, but the exact location will be obfuscated to a coarse level of accuracy.

Which makes me think that Google added coarse location support for the GPS provider. However, I am getting this error:

Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.

Of course the best way forward would be to use the fused location provider API but until then I think the documentation should be clearer about this? Mostly looking for an updated answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷港 2025-01-18 17:56:59

ACCESS_COARSE_LOCATION 仅包含 NETWORK_PROVIDER 的权限,而不包含 GPS 的权限。

从这个 StackOverflow 线程 的评论中了解更多信息,

似乎有一个来自 MarshmallowVersion 的切换。 Pre Marshmallow 的 CoarseLocation 可让您使用 Gps,但为了隐私而混淆位置

ACCESS_COARSE_LOCATION includes permission only for NETWORK_PROVIDER Not GPS.

Got to know more on this from the comments on this StackOverflow Thread

There seems to be a switch from the MarshmallowVersion. Pre Marshmallow the CoarseLocation let you use the Gps but obfuscate the location for privacy

染年凉城似染瑾 2025-01-18 17:56:59

简短的回答是肯定的。

为了完整起见,从 API31 开始,使用 GPS 提供商需要 ACCESS_COARSE_LOCATIONACCESS_FINE_LOCATION 权限。
在较低的 API 上,GPS 提供商仅需要 ACCESS_FINE_LOCATION 权限。

The short answer is Yes.

To be complete, starting from API31 the use of the GPS provider requires both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions.
On lower APIs the GPS provider requires only the ACCESS_FINE_LOCATION permission.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文