【发布时间】:2011-01-10 18:13:16
【问题描述】:
我想用我的应用打开电子邮件中的音频附件。目前我的意图过滤器是这样的:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/wav" />
<data android:scheme="http" android:host="*" android:pathPattern=".*\\.wav"/>
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.wav"/>
<data android:scheme="content" android:host="*" android:pathPattern=".*\\.wav"/>
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.wav"/>
</intent-filter>
这适用于我想要的所有内容,除了电子邮件附件。目前,如果我收到了一个 wav 文件,我唯一能做的就是预览它,然后用 Winamp 打开它(很明显,第 3 方应用程序可以进入)。我找不到我应该添加什么来做到这一点,有人知道吗?
编辑
以下是 LogCat 对此事的看法。当我点击预览时,我得到了
01-10 19:28:52.691: INFO/ActivityManager(109): Starting: Intent { dat=content://gmail-ls/messages/xxxxxxx%40gmail.com/439/attachments/0.1/BEST/false cmp=com.google.android.gm/.ViewAttachmentActivity } from pid 19483
奇怪的是 Winamp 会自动打开,并且没有设置为默认值。我别无选择...
【问题讨论】:
-
我唯一确定的是附件内容提供商不使用文件名,而是使用一些字母数字代码,因此 *.wav 过滤器不适用于此。应改为使用 mimetype。
-
我已经有
<data android:mimeType="audio/wav" />在那里,我应该有其他方法吗? -
不知道...我有这个用于 xml 的
<data android:scheme="content" android:mimeType="text/xml"/>并且它有效。 (类别=默认,操作=视图) -
仍然没有运气,附件的唯一按钮是“预览”,它仍然直接进入 Winamp。
-
你为什么不试试 android:host="gmail-ls"?
标签: android android-intent email-attachments intentfilter