问题解决办法记录(好记性不如烂笔头~电子笔头,嘿嘿)
Caused by: java.lang.SecurityException: UID 10764 does not have permission to content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FPictures%2Fweibo%2Fimg-164873012856083ac9bb75ce06902b5f0230926f11c6be692a0dd64ce144bef6d3d374704c013.jpg [user 0]
小米手机上通过相册修改头像时,报错java.lang.SecurityException闪退,乃Uri的权限问题;裁剪照片时增加以下代码即可解决:文章来源:https://www.toymoban.com/news/detail-498412.html
private void generateXiaomiPermission(Intent intent, Uri cropUri) { if (Build.BRAND.equalsIgnoreCase("XIAOMI") || Build.BRAND.equalsIgnoreCase("Redmi")) { List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; mContext.grantUriPermission(packageName, cropUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setAction(null); intent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name)); break; } } }
搬运参考:https://developer.aliyun.com/article/911761文章来源地址https://www.toymoban.com/news/detail-498412.html
到了这里,关于小米手机通过相册修改头像时报java.lang.SecurityException的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!