为什么 Android PlacePicker 不(!)需要 ACCESS_FINE_LOCATION 许可才能工作?

Why does Android PlacePicker not(!) require ACCESS_FINE_LOCATION permission to work?

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

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

在 Marshmallow 及更高版本上,您还必须请求用户授予此权限。
但它似乎没有执行任何这些操作!
我的应用程序确实如此

但是 运行 Marshmallow 设备上的应用确实启动了 PlacePicker,我可以

任何人都可以证实这一点或解释为什么这个小部件在没有授予适当权限的情况下工作吗?

这个问题已经提出将近一年了,但我一直在努力寻找相同的答案,以便对其他人有所帮助。

这是因为 PlacePicker 与 "intent based request" 一起使用。文档不是很清楚,但它说

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 进行比较,我认为可以使用基于意图的权限,而 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