Get Image From Gallery With Intent
I want to get a image from Gallery with the share command. My current code is: Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType
Solution 1:
A Uri
is not a File
. new File(imageUri.toString())
is always wrong. imageUri.getPath()
only works if the scheme of the Uri
is file
, and in your case, the scheme is probably content
.
Use ContentResolver
and openInputStream()
to get an InputStream
on the file or content identified by the Uri
. Then, pass that stream to BitmapFactory.decodeStream()
.
Also, please decode bitmaps on a background thread, so that you do not freeze your UI while this work is going on.
Post a Comment for "Get Image From Gallery With Intent"