我已经加入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在权限方面有区别吗?