Java 要求您使用ACTION\u OPEN\u文档或相关API获得访问权限
java.lang.SecurityException:权限拒绝:从ProcessRecord{6f31548 13761:com.spotbros.enterprise/u0a88}(pid=13761,uid=10088)打开提供程序com.android.providers.media.MediaDocuments提供程序需要使用操作\打开\文档或相关API获得访问权限 这是我捕获异常的代码:Java 要求您使用ACTION\u OPEN\u文档或相关API获得访问权限,java,android,android-studio,cursor,Java,Android,Android Studio,Cursor,java.lang.SecurityException:权限拒绝:从ProcessRecord{6f31548 13761:com.spotbros.enterprise/u0a88}(pid=13761,uid=10088)打开提供程序com.android.providers.media.MediaDocuments提供程序需要使用操作\打开\文档或相关API获得访问权限 这是我捕获异常的代码: if (scheme.equals("content")) { Cursor c
if (scheme.equals("content")) {
Cursor c = null;
try {
c = SpotbrosApplication.getAppContext().getContentResolver().query(uri, null, null, null, null);
int dataColumnIndex = c.getColumnIndex(MediaStore.MediaColumns.DATA);
if (dataColumnIndex != -1) {
// Simplest case: the query returns a column named "_data" with the file real path.
if (!c.moveToFirst()) {
// The cursor returned empty for any reason.
return null;
}
return c.getString(dataColumnIndex);
}
/*
* The query has not returned the "_data" column, so, as far as we know, the file may well be coming in
* from Google Drive over Lollipop.
*/
return copyGDriveFileToFilesFolder(SpotbrosApplication.getAppContext(), uri);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (c != null) {
c.close();
}
}
}