我的应用程序在我第一次安装应用程序时会要求权限,但是如果我拒绝该权限并再次打开我的应用程序,它就不会请求权限并被卡在
if(ActivityCompat.shouldShowRequestPermissionRationale(Script_list.this, Manifest.permission.WRITE_EXTERNAL_STORAGE))
我不太明白这实际上是做什么的,因为android的文档说它应该告诉用户为什么要求权限
我是否应该在其中进行ActivityCompat.requestPermissions?
if (ContextCompat.checkSelfPermission(Script_list.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(Script_list.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(Script_list.this, "PERMISSION NOT DETECTED", Toast.LENGTH_SHORT).show();
} else {
ActivityCompat.requestPermissions(Script_list.this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
}
else
{
Toast.makeText(Script_list.this, "USER ALREADY ALLOWED", Toast.LENGTH_SHORT).show();
setListView();
}