当前位置: 首页 > 知识库问答 >
问题:

Android 6.0打开失败:EACCES(拒绝权限)

杜正奇
2023-03-14
private File createImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    File image = File.createTempFile(imageFileName, ".jpg", storageDir);
    currentPhotoPath = image.getAbsolutePath();
    return image;
}

共有1个答案

左丘成仁
2023-03-14

Android为Android6.0(Marshmallow)添加了新的权限模型。

http://www.captechconsulting.com/blogs/runtime-permissions-best-practices-and-how-to-gracefully-handle-permission-removement

因此必须检查运行时权限:

它不需要完全支持,直到您选择在应用程序中以23版本为目标。如果您的目标是版本22或更低,那么您的应用程序将在安装时请求所有权限,就像它在运行marshmallow以下操作系统的任何设备上一样。

此信息取自此处:

请检查如何从此链接实现:

 类似资料: