在调试模式下,应用程序权限工作得很好。当使用代码混淆创建签名 apk 时,不会调用 onRequestPermissionsResult ()。它是从 Activity 完成的。targetSdkVersion 也是 23。
public void requestStoragePermissions(){
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.READ_EXTERNAL_STORAGE)
|| ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_STORAGE_ACCESS);
}else{
ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_STORAGE_ACCESS);
}
}
@覆盖
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case REQUEST_STORAGE_ACCESS:
boolean result=PermissionUtil.verifyPermissions(grantResults);
if(result){
checkObbIsAlreadyDownloaded();
}else{
showPermissionAlert();
}
break;
default:Log.d("APK", "from reader");
}
}