我正在使用以下代码来请求权限。
if (ContextCompat.checkSelfPermission(introduction_app.this,
Manifest.permission.READ_PHONE_STATE)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(introduction_app.this,
Manifest.permission.READ_PHONE_STATE)) {
} else {
ActivityCompat.requestPermissions(introduction_app.this,
new String[]{Manifest.permission.READ_PHONE_STATE},
111);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults[0] == -1){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
finishAffinity();
else
finish();
}
}
但如果用户拒绝了请求,则不会再次询问权限。我也没有永远不再问复选框作为其他应用程序。
任何人都可以帮助我吗?
提前完成,
答案 0 :(得分:0)
一旦用户第一次拒绝,它就会显示“再也不会再问”
if (ActivityCompat.shouldShowRequestPermissionRationale(introduction_app.this,
Manifest.permission.READ_PHONE_STATE)) {
ActivityCompat.requestPermissions(introduction_app.this,
new String[]{Manifest.permission.READ_PHONE_STATE},
111);
}