我正在尝试创建一种文件管理器,以允许用户将文件(从文件管理器)上传到互联网。
我想了解如何触发此应用程序。
例如: 当使用 Gmail 并按下添加附件按钮时,Android 会显示两个应用程序(Gallery 和 FileExpert)供我从中选择内容。
- 这是如何实现的?
- 广播什么样的 Intent(如果使用 Intent)?
- 可以调用Gallery和FileManager是什么样的对象 按添加附件按钮?
最佳答案
你是对的,这是使用 Intents 实现的。特别是,调用应用程序(示例中的 Gmail)会发送上传一个或多个文件的 Intent 。对于选择文件, Intent 是 Intent.ACTION_GET_CONTENT .
要将您的应用添加到处理此 Intent 的应用程序列表中,您需要在 list 中指定它。根据this documentation ,它看起来像这样:
<activity android:name=".ui.MyActivity" >
<intent-filter>
<action android:name="android.intent.action.ACTION_GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
关于android - 使用什么样的 Intent 在应用程序之间进行选择,以及如何监听它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18378588/