权限对话框未显示在android棉花糖中
我使用的是nexus 6 android 6.0,仅用于写入外部存储权限对话框,未显示其他危险权限对话框权限对话框未显示在android棉花糖中,android,android-6.0-marshmallow,Android,Android 6.0 Marshmallow,我使用的是nexus 6 android 6.0,仅用于写入外部存储权限对话框,未显示其他危险权限对话框 final private int REQUEST_CODE_ASK_PERMISSIONS = 123; @TargetApi(Build.VERSION_CODES.M) private void insertDummyContactWrapper() { int hasWriteContactsPermission = checkSelfPermission(Manifest
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"
}
舱单:
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
仅针对写入\u外部\u存储权限对话框未显示它显示的其他危险权限
您的另一个危险
权限是读取外部存储
。当我们请求权限并检查权限时,在Android 6.0 UI中,用户授予(或拒绝)权限组<代码>读取外部存储和写入外部存储在同一组中
因此,如果用户先前允许您请求
读取外部存储
,则在调用checkSelfPermission(Manifest.permission.WRITE\u EXTERNAL\u STORAGE)时,您将已经拥有写入外部存储
代码>试试这个可能有用你找到解决方案了吗?