gpt4 book ai didi

Android 6.0 权限.GET_ACCOUNTS

转载 作者:IT老高 更新时间:2023-10-28 21:37:30 26 4
gpt4 key购买 nike

我正在使用它来获得许可:

if (ContextCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {

// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.GET_ACCOUNTS)) {

} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSIONS_REQUEST_GET_ACCOUNTS);

// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}

但是弹出的权限对话框要求用户访问联系人!?!?

在 6.0 之前的 Play 商店中使用

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>

请求名为 Identity 并说明我需要它来获取设备帐户。

最佳答案

这是因为权限组。基本上,权限被放置在不同的组下,如果其中一个被授予,则该组的所有权限都将被授予。

例如。在 "Contacts"下,有写/读联系人和获取帐户,因此当您要求其中任何一个时,弹出窗口会要求提供联系人权限。

通读:Everything every Android Developer must know about new Android's Runtime Permission


编辑 1

只是想我会添加相关的(不是获取帐户,而是获取权限和组)奥利奥更新信息:
来源:https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp

Prior to Android 8.0 (API level 26), if an app requested a permission at runtime and the permission was granted, the system also incorrectly granted the app the rest of the permissions that belonged to the same permission group, and that were registered in the manifest.

For apps targeting Android 8.0, this behavior has been corrected. The app is granted only the permissions it has explicitly requested. However, once the user grants a permission to the app, all subsequent requests for permissions in that permission group are automatically granted.


关于Android 6.0 权限.GET_ACCOUNTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33124930/

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