java.lang.SecurityException:权限拒绝:从ProcessRecord打开提供程序com.android.providers.media.MediaDocumentsProvider {430b1748 29271:com.xxx/u0a88}(pid = 29271,uid = 10088)需要android.permission.MANAGE_DOCUMENTS或android. permission.MANAGE_DOCUMENTS
我已添加MANAGE_DOCUMENTS和READ_EXTERNAL_STORAGE权限,但我仍然收到此错误.违规代码:
public static String getImagePath(HailoDriverApplication app, Uri uri) {
Cursor cursor = null;
if (uri == null) {
return null;
}
try {
cursor = app.getContentResolver().query(uri, new String[] {
MediaStore.Images.Media.DATA
}, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
if (cursor.moveToFirst()) {
return cursor.getString(column_index);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
正如所要求的清单片段:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.x.x.x" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" /> …Run Code Online (Sandbox Code Playgroud)