-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Android11 打开相册选择图片返回后无法显示。拍照没有问题
报错:
E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaDocumentsProvider uri content://com.android.providers.media.documents/document/image%3A35 from pid=25351, uid=10155 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
现使用代码:
private Intent getFileChooserIntent() {
Intent mIntent = null;
if (mIsAboveLollipop && mFileChooserParams != null && (mIntent = mFileChooserParams.createIntent()) != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && mIntent.getAction().equals(Intent.ACTION_GET_CONTENT)) {
mIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
}
return mIntent;
}
Intent i = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
i.setAction(Intent.ACTION_OPEN_DOCUMENT);
} else {
i.setAction(Intent.ACTION_GET_CONTENT);
}
i.addCategory(Intent.CATEGORY_OPENABLE);
if (TextUtils.isEmpty(this.mAcceptType)) {
i.setType("*/*");
} else {
i.setType(this.mAcceptType);
}
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
return mIntent = Intent.createChooser(i, "");
}
Metadata
Metadata
Assignees
Labels
No labels