【发布时间】:2018-10-28 22:42:01
【问题描述】:
java.lang.SecurityException: Permission Denial: 从未导出的 ProcessRecord{932688f 12849:mobi.hubbler.app/u0a158} (pid=12849, uid=10158) 打开提供程序 com.miui.gallery.provider.GalleryOpenProvider来自 uid 10034
InputStream is = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
is = context.getContentResolver().openInputStream(bitmapUri);
BitmapFactory.decodeStream(is, null, options);
试图从 uri 中获取位图。此问题仅发生在 MI(xiaomi) 设备上。
【问题讨论】:
-
你是怎么得到
bitmapUri的? -
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);意图.setType(IMAGE_MIME_TYPE);
-
你在
onActivityResult()的回答中的代码是吗? -
这是 onActivityResult 中的代码 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == GALLERY) { if(data!=null) { Uri bitmapUri = data.getData(); } } }
-
该代码不执行任何操作。你设置一个本地的
bitmapUri值,然后离开。您的错误感觉就像您将Uri传递给另一个活动或服务,或者您将其保存在某个地方(文件、数据库、SharedPreferences)。您只能在请求它的原始活动中使用此Uri,如果您使用FLAG_GRANT_READ_URI_PERMISSION,则只能在另一个活动或服务中使用。请参阅this blog post 了解更多信息。
标签: android inputstream android-bitmap xiaomi