gpt4 book ai didi

android - 未显示权限对话框android marshmallow

转载 作者:行者123 更新时间:2023-11-29 20:22:37 26 4
gpt4 key购买 nike

我使用的是 nexus 6 android 6.0,仅针对 WRITE_EXTERNAL_STORAGE 权限对话框未显示,因为它正在显示其他危险权限。

final private int REQUEST_CODE_ASK_PERMISSIONS = 123;

@TargetApi(Build.VERSION_CODES.M)
private void insertDummyContactWrapper() {
int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);

// Here, thisActivity is the current activity
if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {

// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.

} else {

// No explanation needed, we can request the permission.

ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
110);

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

构建:

defaultConfig {
applicationId "com.example.application"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}

list :

uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"

最佳答案

only for WRITE_EXTERNAL_STORAGE permission dialog is not showing for other dangerous permission it is showing

您的其他危险权限是READ_EXTERNAL_STORAGE。当我们请求权限并检查权限时,在 Android 6.0 UI 中,用户授予(或拒绝) 权限。 READ_EXTERNAL_STORAGEWRITE_EXTERNAL_STORAGE 在同一组中。

因此,如果用户先前批准了您对 READ_EXTERNAL_STORAGE 的请求,那么在您调用 checkSelfPermission(Manifest.permission .WRITE_EXTERNAL_STORAGE);.

关于android - 未显示权限对话框android marshmallow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32968830/

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