问题描述
当我尝试将照片从Google相册共享到我的应用程序时,出现以下异常:
java.lang.SecurityException: UID 10155 does not have permission to content://com.google.android.apps.photos.contentprovider/0/1/mediakey%3A%2Flocal%253Af1161f0d-d189-487f-9d29-d43f15e3ea1a/REQUIRE_ORIGINAL/NONE/image%2Fjpeg/1725628227 [user 0]
和
java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord{f1318dd 13216:com.spotbros.defense/u0a155} (pid=13216,uid=10155) that is not exported from UID 10119
这是我得到这些的代码的一部分:
if (scheme.equals("content")) {
try (Cursor c = SpotbrosApplication.getAppContext().getContentResolver().query(uri,null,null)) {
//We grant permissions to share content from media providers
//SpotbrosApplication.getAppContext().grantUriPermission(SpotbrosApplication.getAppContext().getPackageName(),// uri,Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
if (c != null && c.movetoFirst()) {
int dataColumnIndex = c.getColumnIndex(MediaStore.MediaColumns.DATA);
if (dataColumnIndex != -1) {
// Simplest case: the query returns a column named "_data" with the file real path.
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 (IllegalArgumentException e) {
// Could not resolve the file name
return null;
} catch (IOException e) {
// File not found or not openable
return null;
} catch (Exception e) {
e.printstacktrace();
return null;
}
} else if (scheme.equals("file")) {
return uri.getPath();
}
return null;
}
我不想使用外部库。有想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)