"No content provider execution " 将 uri 转换为位图时出错

"No content provider execution " error while converting uri to Bitmap

我正在尝试从 Uri 检索图像,首先我从图库中选择图像,然后使用意图传递 imagePath 并尝试使用此代码从 Uri 获取图像-

        Uri imgUri = Uri.parse(getIntent().getExtras().getString("imageUri"));


        Log.d("" + imgUri, " here it is");


        InputStream PIS;


            try {

                PIS = getContentResolver().openInputStream(imgUri);
                 mImage = BitmapFactory.decodeStream(PIS);


            } catch (Exception e){

                Log.d("go home you're drunk "+e,"");
            Toast toast = Toast.makeText(this, ""+e, Toast.LENGTH_LONG);
            toast.show();

            }

但收到此错误

01-19 04:59:50.627 847-858/? I/ActivityManager: START u0 {cmp=pb.imagepicker/.CropActivity (has extras)} from uid 10060 on display 0
01-19 04:59:50.668 6072-6072/? D//storage/emulated/0/DCIM/Camera/IMG_20160118_124651.jpg:  here it is
01-19 04:59:50.668 6072-6072/? D/go home you're drunk java.io.FileNotFoundException: No content provider: /storage/emulated/0�di[ 01-19 04:59:50.769  6072: 6085 W/EGL_emulation: eglSurfaceAttrib not implemented

// 一些额外的错误

 01-19 05:33:06.419 6565-6580/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe8e32360, error=EGL_SUCCESS
 01-19 05:33:06.564 6565-6580/? W/EGL_emulation: eglSurfaceAttrib not implemented
 01-19 05:33:06.564 6565-6580/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe8e328c0, error=EGL_SUCCESS

你可以看到我的 imgUri 上有 uri,不知道做错了什么或遗漏了什么,如果有人知道遗漏了什么,请纠正我,谢谢 :)

我正在使用 genyMotion 模拟器,这是问题的原因吗?

将此权限附加到您的 AndroidManifest.xml 文件中

 <uses-permission 
        android:name="android.permission.READ_EXTERNAL_STORAGE" />

并使用

Uri imgUri = Uri.parse("file://"+getIntent().getExtras().getString("imageUri"));

遇到了同样的问题,可能是因为你的模拟器改变了我的模拟器,我从 genymotion 转移到 blueStack 并且它工作不知道为什么会发生,你应该试一试

http://www.bluestacks.com/download.html