如何使用Intent.ACTION_VIEW查看文件夹的内容? [英] How can I use Intent.ACTION_VIEW to view the contents of a folder?

查看:961
本文介绍了如何使用Intent.ACTION_VIEW查看文件夹的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图查看使用意图在一个特定的文件夹中的图片。我的code是如下:

I'm trying to view the images in a specific folder using an intent. My code is as follows:

Intent intent = new Intent();  
intent.setAction(Intent.ACTION_VIEW);  
Uri imgUri = Uri.parse("file://sdcard/download");  
intent.setDataAndType(imgUri, "image/*");  
startActivity(intent);  

不过,每次运行时,我得到的日志中这样的信息:

However, each time it runs, I get this message in the log:

02-25 00:40:16.271:ERROR /(8359):无法打开'/下载
  02-25 00:40:16.271:ERROR /(8359):无法打开'/下载

02-25 00:40:16.271: ERROR/(8359): can't open '/download'
02-25 00:40:16.271: ERROR/(8359): can't open '/download'

我是什么做错了吗?

推荐答案

尝试这样的事情

Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);

Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);

这篇关于如何使用Intent.ACTION_VIEW查看文件夹的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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