开发者

How to display images stored in the Cache Folder using ACTION_VIEW

I'm creating an app that downloads a lot of pictures from a website and stores them all in the cache folder so that it won't take up too much space on the phone.

Now my problem is that I want the user to be able to click on an image and it will load up the image in the default android picture viewer. I've researched and figured out how to do that no problem, but I'm not 100% sure if this method will work. I can call the Intent no problem and the Pictureviewer opens but it doesn't display the images?

Can anyone let me know if this is possible to do this way? Thanks

Here is the code calling the intent and getting the directory and files...

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 fi开发者_如何学Pythonle = new File(cacheDir, fileName);

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file),"image/png");
startActivity(i);*/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜