需要做的功能是,获取到WRITE_EXTERNAL_STORAGE动态权限,然后获取到手机内所有pdf和word文档.现在的问题就是,除了锤子坚果pro2手机,其他手机都是正常的,用坚果pro2并没有弹出任何获取动态权限的页面,打开获取手机文档的页面后手机就直接黑屏了,没有看到任何错误日志.请问这种问题应该怎么解决?
下面是获取动态权限和获取手机内所有pdf和word文档的代码:
1.获取动态权限:
//获取手机内所有文档和保存手写签名所需权限
` new RxPermissions(this) .request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.compose(RxUtil.lifeCycle(this))
.subscribe(aBooleans -> {
if (aBooleans) {
} else {
ToastUtils.showLong(R.string.please_open_permission);
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
}
});`
2.获取手机内所有pdf和word文档:
` public static List getPdfAndDoc(String path) {
List list = new ArrayList<>();
File file = new File(path + "/");
if (file == null) {
return null;
}
File[] files = file.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
//是否是文件夹
if (files[i].isDirectory()) {
getAllPDF(files[i].getPath());
} else {
if (files[i].getName().endsWith(".docx")||files[i].getName().endsWith(".doc")||files[i].getName().endsWith(".pdf")) {
//获取到的pdf文件
String name = files[i].getName();//获取所有pdf文件名
String absolutePath = files[i].getAbsolutePath();//获取所有pdf文件路径
DocSelectBean bean=new DocSelectBean();
bean.setDocName(name);
bean.setDocPath(absolutePath);
list.add(bean);
LogUtils.d("1730= " + absolutePath);
}
}
}
}
return list;
}`