Android 6.0 打开失败:EACCES(权限被拒绝)
我已将包含,,添加到。uses-permission
WRITE_EXTERNAL_STORAGE
MOUNT_UNMOUNT_FILESYSTEMS
READ_EXTERNAL_STORAGE
AndroidManifest.xml
当我尝试在Nexus5(Android 6.0)中运行我的应用程序时,它抛出了如下异常:
java.io.IOException: open failed: EACCES (Permission denied)
我尝试了另一款Android手机(Android 5.1),一切都很好。代码如下:
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;
}
Android 6.0 在权限方面有区别吗?