在Android中打开电子邮件附件

时间:2010-06-13 09:26:53

标签: android

我尝试使用我的活动打开特定的电子邮件附件类型,附件本身是一个纯文本窗口样式ini文件,扩展名为* .os。在电子邮件中,此文件附加为“application / octet-stream”。我尝试使用以下intent-filter来捕获我的活动附件:

         <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="http" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="https" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="content" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="file" android:host="*" android:pathPattern=".*\\.os"/>
        </intent-filter>

电子邮件应用程序正在获取附件,但随后告诉我“附件无法显示”。我能做什么?我该怎么调试呢?

2 个答案:

答案 0 :(得分:1)

它应该只是一个文件方案,所以我会消除其他人并尝试使用它并将mimeType包含为通配符(“*”或“* / *”):

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="file" />
    <data android:mimeType="*" />
    <data android:pathPattern=".*\\.os" />
    <data android:host="*" />
</intent-filter>

如果这不起作用,可以尝试使用android.intent.action.MAIN进行操作。检查日志以查看是否为您提供了与任何内容不匹配的意图的详细信息。

答案 1 :(得分:0)

我的解决方案适用于.wav个文件,用于设置mimeType:

     <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:mimeType="application/os" />
    </intent-filter>
相关问题