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

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

问题描述

我想为可以返回任何类型的文件的应用程序启动一个意向书。

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

目前我使用(我从Android电子邮件源代码复制文件附件)

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上显示Gallery和Music player。此设备上有一个文件浏览器,我希望它出现在列表中。我也希望相机应用程序在列表中显示,以便用户可以拍摄照片并通过我的应用程序发送。
如果我安装了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.

任何想法我怎么能达到这个目标?我很确定我已经看到默认的文件管理器出现在这样一个菜单中来选择一个文件,但是我记不起哪个应用程序。

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上的Intent选择任何种类的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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