EACCES(权限被拒绝)Android

问题描述 投票:0回答:1

GOAL:要对image/content进行压缩,请使用意图通过外部源(例如sd卡,内部或驱动器)进行检索。

我能够获得所检索内容的实际路径,但是当我尝试使用压缩库(zetbaitsu / Compressor对其进行压缩时,其抛出错误]]

打开失败:EACCES(权限被拒绝)。

我已经交叉检查了我的权限,并尝试了多种方法来确认权限访问,仍然是抛出错误。

这是我的职能:

void handleSendImage(Intent intent) {
    try {
        Uri imageUri =  intent.getParcelableExtra(Intent.EXTRA_STREAM);
        Log.d(TAG, "handleSendImage: " + imageUri.toString());
        File imageFile = new File(getFilePath(this, imageUri));
        Log.d(TAG, "handleSendImage: " + Uri.fromFile(imageFile));
        File compressedFile = new Compressor(this).compressToFile(imageFile);

    } catch (Exception e) {
        Log.e(TAG, "handleSendImage: " + e.getMessage());
    }
}

这是我的日志输出:

handleSendImage: content://com.android.providers.media.documents/document/image%3A30

handleSendImage: file:///storage/emulated/0/Download/4c568534307d605ed94878dc06d933ee.jpg

handleSendImage: /storage/emulated/0/Download/4c568534307d605ed94878dc06d933ee.jpg: open failed: EACCES (Permission denied)

目标:对图像/内容执行压缩,使用意图通过外部来源(例如,SD卡,内部或驱动器)检索图像/内容。我能够获取检索到的内容的实际路径,但是当我...

android compression image-compression file-access
1个回答
0
投票

android:requestLegacyExternalStorage="true"

© www.soinside.com 2019 - 2024. All rights reserved.