Android 安卓6.0:多少次;应显示“请求许可理由”;接到电话了吗?
我最近开始开发android 6.0——运行时权限请求 我想知道调用了多少次Android 安卓6.0:多少次;应显示“请求许可理由”;接到电话了吗?,android,android-6.0-marshmallow,android-permissions,Android,Android 6.0 Marshmallow,Android Permissions,我最近开始开发android 6.0——运行时权限请求 我想知道调用了多少次showldRequestPermissionRegulation()方法 这是我的代码: @Override protected void onResume() { super.onResume(); if ((ContextCompat.checkSelfPermission(LaunchActivity.this, Manifest.permission.WRITE_EX
showldRequestPermissionRegulation()
方法
这是我的代码:
@Override
protected void onResume() {
super.onResume();
if ((ContextCompat.checkSelfPermission(LaunchActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED)){
dbOperation();
if (NetworkUtil.isServiceReachable(this)){
checkAppVersion();
} else {
startApplication();
}
} else {
if (!ActivityCompat.shouldShowRequestPermissionRationale(LaunchActivity.this,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
showMessageOKCancel("You need to allow access to Storage/Media for storing your Records.",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(LaunchActivity.this,new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
PermissionConstants.WRITE_EXTERNAL_STORAGE_PERMISSION);
}
});
return;
}
ActivityCompat.requestPermissions(LaunchActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},PermissionConstants.WRITE_EXTERNAL_STORAGE_PERMISSION);
return;
}
}
在回调方法中,我这样做:
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode){
case PermissionConstants.WRITE_EXTERNAL_STORAGE_PERMISSION:{
if (grantResults.length>0 && grantResults[0]== PackageManager.PERMISSION_GRANTED){
dbOperation();
// Permission is granted Read and Write external storage.
if (NetworkUtil.isServiceReachable(this)){
checkAppVersion();
} else {
startApplication();
}
}else {
if (!ActivityCompat.shouldShowRequestPermissionRationale(LaunchActivity.this,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
showMessageOKCancel("You need to allow access to Storage/Media for storing your Records.",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(LaunchActivity.this,new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
PermissionConstants.WRITE_EXTERNAL_STORAGE_PERMISSION);
}
});
return;
}else {
ActivityCompat.requestPermissions(LaunchActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},PermissionConstants.WRITE_EXTERNAL_STORAGE_PERMISSION);
}
//break;
}
}
break;
default:super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
在这种情况下。当用户拒绝权限而不选择“不再询问”时,android会显示“请求权限”对话框两次,然后进入无限循环
不再询问
复选框,会发生什么情况showldRequestPermissionRegulation()
方法
如果是,有多少次
如果否为什么不
任何帮助都将不胜感激
它只会打一次电话。