user11230 user11230 - 1 month ago 9
Android Question

How to use ACTION_VIEW intent when loading image with Glide

I know that I can use an ACTION_VIEW intent if I have the image saved physically on the device. But in my case I laod the images dynamically from an url, like this:

Glide.with(getActivity())
.load(mImageUrl)
.into(mImageView);


Now I want to be able to open the image located at
mImageUrl
with the user's preferred gallery app when he clicks a button. How can I do that? Is it even possible or do I have to download and save the image?

Answer

I fixed it. Basically Glide stores the downloaded image in the cache, and I couldn't get a download file path. So I did the following:

When the user clicks the "share" button I will download the image again (with glide) and save it in a .jpg file in the user's sdcard. Then I will use an ACTION_VIEW intent with the uri of the downloaded jpg.

Then the image stays saved in the user's gallery.

Comments