我正在创建一个应用程序,它从网站下载大量图片并将它们全部存储在缓存文件夹中,这样它就不会占用手机太多空间。
现在我的问题是我希望用户能够单击图像,它将在默认的 android 图片查看器中加载图像。我已经研究并弄清楚如何做到这一点没问题,但我不能 100% 确定这种方法是否有效。我可以调用 Intent 没问题,并且 Pictureviewer 会打开,但它不显示图像?
谁能让我知道这是否可以这样做?谢谢
这是调用意图并获取目录和文件的代码......
URL url = null;
try
{
url = new URL(assetsToFullScreen[arg2]);
} catch (MalformedURLException e)
{
e.printStackTrace();
}
File cacheDir = SingleArticle.this.getCacheDir();
String fileName = url.getFile();
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
File file = new File(cacheDir, fileName);
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file),"image/png");
startActivity(i);*/