gpt4 book ai didi

android - 为什么 Android PlacePicker 不(!)需要 ACCESS_FINE_LOCATION 权限才能工作?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:11:25 24 4
gpt4 key购买 nike

PlacePicker 是添加到 com.google.android.gms:play-services-places:9.4.0 中的一个有用的小部件。在这里找到描述:PlacePicker

文档明确指出您需要 ACCESS_FINE_LOCATION 权限才能正常工作。

在 Marshmallow 及更高版本上,您还必须请求用户授予此权限。
但它似乎在不执行任何这些操作的情况下工作!
我的应用程序可以

  • 提供 map API key
  • 在AndroidManifest中定义权限
  • 随时要求用户授予此权限

但在 Marshmallow 设备上运行该应用程序确实会启动 PlacePicker,我可以

  • 正确选择一个地方(没有 API key 是不可能的)。
  • 通过 MyLocation 按钮转到“我的位置”(可能没有 API key )

谁能证实这一点或解释为什么这个小部件在没有授予适当权限的情况下工作?

最佳答案

这个问题已经有将近一年的历史了,但我试图找到相同的答案,以便它可以帮助其他人。

这是因为 PlacePicker 使用“基于 Intent 的请求”。文档不是很清楚,但它说

1: Only use the permissions necessary for your app to work. Depending on how you are using the permissions, there may be another way to do what you need (system intents, identifiers, backgrounding for phone calls) without relying on access to sensitive information. Source

在这里给出一些线索:

If your requirement for access to user data is infrequent — in other words, it's not unacceptably disruptive for the user to be presented with a runtime dialogue each time you need to access data — you can use an intent based request. Android provides some system intents that applications can use without requiring permissions because the user chooses what, if anything, to share with the app at the time the intent based request is issued. Source

我已经弄明白了如何使用 Marshmallow 和 Lollipop 设备测试权限用例,并将结果与​​ PlacePicker 进行比较,我认为可以将基于 Intent 的权限与 MediaStore 进行比较根据文档使用这种权限:

For example, an intent action type of MediaStore.ACTION_IMAGE_CAPTURE or MediaStore.ACTION_VIDEO_CAPTURE can be used to capture images or videos without directly using the Camera object (or requiring the permission). In this case, the system intent will ask for the user’s permission on your behalf every time an image is captured. For example, an intent action type of MediaStore.ACTION_IMAGE_CAPTURE or MediaStore.ACTION_VIDEO_CAPTURE can be used to capture images or videos without directly using the Camera object (or requiring the permission). In this case, the system intent will ask for the user’s permission on your behalf every time an image is captured. Source

关于android - 为什么 Android PlacePicker 不(!)需要 ACCESS_FINE_LOCATION 权限才能工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38805056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com