I am trying to get a FileInputStream object for an image that the user selects from the image gallery. This is the Android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI
content://media/external/images/media/3
When I try to create a Java URI object from this object, I get an IllegalArgumentException with a description of the expected Expected file scheme in the URI: content: // media / external / images / media / 3, while in the android URI the scheme is displayed as content
Update : I never found a solution to the original question. But if you need an image byte stream in the image gallery, this piece of code will do it.
Bitmap bitmap = Media.getBitmap(getContentResolver(), imageUri); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); ByteArrayInputStream fileInputStream = new ByteArrayInputStream(bytes.toByteArray());
android uri fileinputstream android-bitmap
lostInTransit Feb 18 '09 at 5:05 2009-02-18 05:05
source share