In my Project I’m saving a given Bitmap to my phone’s local gallery with the following method:
Bitmap bmp = some_fancy_bitmap;
imgeUrl = MediaStore.Images.Media.insertImage(getContentResolver(), bmp, "some Title", "some_Description");
MediaStore.Images.Media.insertImage gets the source Bitmap, saves it, and returns a String with the URL to the newly created image, or null if the image failed to be stored for any reason.
This is an example of imageUrl I am returned in case of successful saving: content://media/external/images/media/223.
I’d now like to pass this Bitmap to a new Activity, in the form of the Uri of the resource.
How can I transform the imageUrl I was returned, or directly the Bitmap bmp, into the resource’s Uri?
Note: imageUrl is a String, and I want to get an Uri, not an URI.
Uri.parse(String url ) Creates a Uri which parses the given encoded URI string.
Parameters:
uriString an RFC 2396-compliant, encoded URI
Returns:
Uri for this given uri string
Throws:
NullPointerException – if uriString is null