Reputation:
i am trying to retrieve an image from the Uri
, firstly i selected the image from gallery then passed the imagePath using an intent and trying to get the image from Uri
by using this codes -
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();
}
but am getting this error
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
// some extra errors
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
you can see i have the uri
on my imgUri
, don't know what am doing wrong or missing if anybody knows what am missing than please correct me thanks :)
am using genyMotion emulator is it the cause of problem ?
Upvotes: 4
Views: 9096
Reputation:
had faced the same problem , maybe its happening because of your emulator changing the emulator worked form me , i moved from genymotion to blueStack and it worked for don't know why it happened , you should give it a shot
http://www.bluestacks.com/download.html
Upvotes: 0
Reputation: 27221
Append this permissions into your AndroidManifest.xml
file
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
and use
Uri imgUri = Uri.parse("file://"+getIntent().getExtras().getString("imageUri"));
Upvotes: 6