使用 Glide 加载图像时如何使用 ACTION_VIEW 意图 [英] How to use ACTION_VIEW intent when loading image with Glide

查看:34
本文介绍了使用 Glide 加载图像时如何使用 ACTION_VIEW 意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如果我将图像物理保存在设备上,我可以使用 ACTION_VIEW 意图.但就我而言,我从 url 动态加载图像,如下所示:

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);

现在我希望能够在用户单击按钮时使用用户首选的图库应用程序打开位于 mImageUrl 的图像.我怎样才能做到这一点?甚至可能还是我必须下载并保存图像?

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?

推荐答案

我修复了它.基本上 Glide 将下载的图像存储在缓存中,我无法获得下载文件路径.所以我做了以下事情:

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:

当用户单击共享"按钮时,我将再次下载图像(使用滑行)并将其保存在用户 SD 卡中的 .jpg 文件中.然后我将使用 ACTION_VIEW Intent 和下载的 jpg 的 uri.

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.

这篇关于使用 Glide 加载图像时如何使用 ACTION_VIEW 意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆