BitmapFactory.decodeFile e/bitmapfactory 无法解码流 java.io.filenotfoundexception EACCES(权限被拒绝)

BitmapFactory.decodeFile e/bitmapfactory unable to decode stream java.io.filenotfoundexception EACCES (Permission denied)

我试图从存储中拍摄一张照片,并使用 BitmapFactory.decodeFile 在 ImageView 中显示它,但我发现错误无法解码流 java.io.filenotfoundexception EACCES(权限被拒绝),我正在使用 android 10 模拟器 API 30.

这是我的代码:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK)
        {
            if(requestCode == REQUEST_GALLERY)
            {
                Uri dataimage = data.getData();
                String[] imageprojection = {MediaStore.Images.Media.DATA};
                Cursor cursor = getContentResolver().query(dataimage,imageprojection,null,null,null);

                if (cursor != null)
                {
                    cursor.moveToFirst();
                    int indexImage = cursor.getColumnIndex(imageprojection[0]);
                    part_image = cursor.getString(indexImage);

                    Toast.makeText(this, "Image Saved Part Image :" + part_image, Toast.LENGTH_SHORT).show();

                    if(part_image != null)
                    {
                        File image = new File(part_image);
                        imgHolder.setImageBitmap(BitmapFactory.decodeFile(image.getAbsolutePath()));
                        Toast.makeText(this, "Image Saved Part Image :" + image, Toast.LENGTH_SHORT).show();
                    }
                }
            }
        }
    }
    

我已将此添加到我的 Android 清单中:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

还有这个:

<application
...
android:requestLegacyExternalStorage="true">

这是我的错误日志:

E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/0000-0000/DCIM/Camera/IMG-20200714-WA0008.jpg: open failed: EACCES (Permission denied)

任何帮助解决方案?

imgHolder.setImageUri(data.getData());