Android Intent 类似于 Gmail 的 attach Intent

标签 android

当我为我的 ACTION_GET_CONTENT Intent 获取 Activity 选择器时,有一些我不想出现的应用程序,例如那些将首先创建内容然后将 URI 传递给我的应用程序,例如录音机。

当您使用 Gmail 并尝试附加文件时,您只会看到从 SDCard 中挑选数据的应用程序/Activity ,例如 Gallery,在我的例子中是 Astro(文件管理器应用程序)。

所以我的问题是,Gmail 使用什么样的 Intent 进行附加?

这是我的代码,因为我得到了录音机等应用程序,所以一定缺少了一些东西。

Intent action = new Intent(Intent.ACTION_GET_CONTENT);  
action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);  
startActivityForResult(Intent.createChooser(action, "Upload file from..."), 1);

谢谢!

问候
托拜厄斯

最佳答案

是这样的:

Intent intent = new Intent();
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select file"), 1);

关于Android Intent 类似于 Gmail 的 attach Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4204719/

相关文章:

android - 如何防止指纹扫描仪被选为游戏 handle ?

android - 您如何在不基于 gradle 构建的 android 项目中使用 ShowcaseView 库?

android - NFC Offhost 路由到 Nexus 5X 和 Nexus 6P 上的 UICC

java - 如何从图库中的图像中获取(提取)文本并搜索该文本 - Android?

android - Android 6.0 中的蓝牙简单安全配对不起作用

android - 查找 JSON 数组的列表项索引

java - Android中如何淡出滑动层的背景

java - 在 Android 中将月份 +1 添加到日历月份中的日历问题

android - 暂停或停止 fragment 后未显示键盘

android - 在 Android 中为 ProgressBar 添加图标