Android 6.0 打开失败:EACCES(权限被拒绝) [英] Android 6.0 open failed: EACCES (Permission denied)

查看:51
本文介绍了Android 6.0 打开失败:EACCES(权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了uses-permission 包括WRITE_EXTERNAL_STORAGEMOUNT_UNMOUNT_FILESYSTEMSREAD_EXTERNAL_STORAGEAndroidManifest.xml.

I have added uses-permission including WRITE_EXTERNAL_STORAGEMOUNT_UNMOUNT_FILESYSTEMSREAD_EXTERNAL_STORAGE to AndroidManifest.xml.

当我尝试在 Nexus5 (Android 6.0) 中运行我的应用程序时,它抛出了如下异常:

When I tried to run my application in Nexus5 (Android 6.0),it threw a exception as below:

java.io.IOException:打开失败:EACCES(权限被拒绝)

我尝试了另一部 Android 手机(Android 5.1),一切正常.代码如下:

And I tried another Android phone(Android 5.1),everything was OK.Here's the code:

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 在权限上有区别吗?

Does Android 6.0 have difference about permission?

推荐答案

Android 为 Android 6.0 (Marshmallow) 添加了新的权限模型.

Android added new permission model for Android 6.0 (Marshmallow).

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

所以你必须检查Runtime Permission :

什么是运行时权限?

在 Android 6.0 Marshmallow 中,Google 引入了一种新的权限模型,可让用户更好地了解应用程序可能请求特定权限的原因.与用户在安装时盲目接受所有权限不同,现在会提示用户在应用程序使用过程中需要时接受权限.

With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be requesting specific permissions. Rather than the user blindly accepting all permissions at install time, the user is now prompted to accept permissions as they become necessary during application use.

何时实施新模型?

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

it doesn’t require full support until you choose to target version 23 in your application. If you are targeting version 22 or below, your application will request all permissions at install time just as it would on any device running an OS below Marshmallow.

此信息取自此处:

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

Please check How to implement from this link :

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

这篇关于Android 6.0 打开失败:EACCES(权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆