在Android中打开电子邮件附件

zeh*_*rer 7 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>
Run Code Online (Sandbox Code Playgroud)

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

Ian*_*ton 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>
Run Code Online (Sandbox Code Playgroud)

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