简体   繁体   English

Android Intent就像Gmail的附加Intent一样

[英]Android Intent like Gmail's attach Intent

When I get my activity chooser for my ACTION_GET_CONTENT Intent there is applications I don't want to be there, like the ones who will first create content and then pass the URI to me, like the Voice Recorder. 当我为我的ACTION_GET_CONTENT Intent获取我的活动选择器时,有些应用程序我不想在那里,比如那些首先创建内容然后将URI传递给我的人,比如Voice Recorder。

When you use Gmail and try to attach a file you will only see the applications/activities that picks data from your SDCard like Gallery, and in my case Astro (file manager application). 当您使用Gmail并尝试附加文件时,您将只看到从SDCard中选择数据的应用程序/活动,例如图库,以及我的案例Astro(文件管理器应用程序)。

So my question is, what kind of Intent does Gmail use for their Attach? 所以我的问题是,Gmail使用什么样的Intent进行附加?

Here is my code, something must be missing since I get applications like Voice Recorder and so on. 这是我的代码,因为我得到了Voice Recorder等应用程序,所以必须缺少一些东西。

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

Thank you! 谢谢!

Regards 问候
Tobias 托比亚斯

putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filePath));

编辑:可能重复等等

This is how it's done: 这就是它的完成方式:

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM