通过在Android上的意向选择任何类型的文件 [英] Pick any kind file via an Intent on Android

查看:551
本文介绍了通过在Android上的意向选择任何类型的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始一个intentchooser的应用程序可以返回任何类型的文件

I would like to start an intentchooser for apps which can return any kind of file

目前我使用(这是我从Android邮件源$ C ​​$ C复制的文件附件)

Currently I use (which I copied from the Android email source code for file attachment)

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
Intent i = Intent.createChooser(intent, "File");
startActivityForResult(i, CHOOSE_FILE_REQUESTCODE);

不过,这只能说明我的GALAXY S2画廊和音乐播放器。有此设备上的文件浏览器,我希望它出现在列表中。我还想相机应用显示在列表中,以便用户可以拍摄一张照片,并通过我的应用程序发送。 如果我安装的Astro文件管理器,它会回应的意图了。我的客户是唯一的GALAXY SII拥有者,我不想强​​迫他们安装的Astro文件管理器,因为他们已经有了一个基本的,但足够的文件管理器。

But it only shows "Gallery" and "Music player" on my Galaxy S2. There is a file explorer on this device and I would like it to appear in the list. I would also like the camera app to show in the list, so that the user can shoot a picture and send it through my app. If I install Astro file manager it will respond to that intent, too. My customers are Galaxy SII owners only and I don't want to force them to install Astro file manager given that they already have a basic but sufficient file manager.

的我怎么能做到这一点任何想法?我是pretty的肯定,我已经看到默认的文件管理器出现在这样的菜单中选择一个文件,但我不记得在其中的应用程序。

Any idea of how I could achieve this ? I am pretty sure that I already saw the default file manager appear in such a menu to pick a file, but I can't remember in which app.

谢谢!

推荐答案

不为相机,但对于其他文件。

Not for camera but for other files..

在我的设备我有 ES文件浏览器安装和这只是事情的作品在我的情况。

In my device I have ES File Explorer installed and This simply thing works in my case..

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_REQUEST_CODE);

这篇关于通过在Android上的意向选择任何类型的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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