Gmail 附件和自定义扩展程序

2024-01-07

我目前正在开发一个 Android 应用程序,该应用程序读取具有自定义扩展名的文件。 其中一项强制性功能是,当用户收到带有附件 .our 扩展名的邮件时,该应用程序必须由 Gmail 推荐。

我做了一些研究,发现Android上的gmail客户端不依赖扩展名,因为在启动意图的数据中,建议的文件没有扩展名。它仅依赖于邮件客户端给出的 mime 类型。

问题是我们的自定义文件在邮件客户端之间的检测方式不同。例如,如果我使用 Gmail 网页向自己发送自定义文件,则 mime 类型将检测为 application/octet-stream。如果我的一个朋友使用苹果邮件桌面软件发送,它会被检测为文本/xml(这会很好)。在另一个邮件客户端 Evolution 上,mime 类型是文本/纯文本...

我们的应用程序无法处理所有这些类型!否则,将针对每种类型的附件提出建议......

有什么解决办法吗?


使用 gmail

发送文件的代码:

sendIntent.setType("application/calc1");

意图过滤器:

           <!-- Filter to open file with gmail version < 4.2 -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/calc1" />
            <data android:pathPattern=".*\\.calc1" />
            <data android:host="*" />
        </intent-filter>

        <!-- Filter to open with file browser or google drive -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="file" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.calc1" />
            <data android:host="*" />
        </intent-filter>

        <!-- Filter to open file with gmail version 4.2 -->
        <!-- Save file first with "save" button otherwise gmail crashes -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/octet-stream" />
            <data android:pathPattern=".*\\.calc1" />
            <data android:host="*" />
        </intent-filter>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gmail 附件和自定义扩展程序 的相关文章

随机推荐