Gmail附件和自定义扩展 [英] Gmail attachment and custom extension

查看:227
本文介绍了Gmail附件和自定义扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的工作在读取文件自定义扩展的Andr​​oid应用程序。 其中的强制性特点,是该应用程序必须提出的Gmail,当用户收到带有附件.ourextension邮件。

I work currently on an Android application that read file with a custom extension. One of the mandatory features, is that the app must be proposed by gmail when the user receive a mail with the attachment .ourextension.

我做了一些研究,发现在Android的Gmail客户端不依赖于扩展,因为在推出意图提出的文件没有扩展名的数据。它只能依靠MIME类型的邮件客户端给出。

I did some research, and found that gmail client on Android doesn't rely on the extension, because in the data of the launched intent the file proposed has no extension. It only rely on the mime-type given by the mail client.

的问题是,我们的定制文件中没有检测到邮件客户端之间的方式相同。举例来说,如果我发送给自己的Gmail的网页我们的自定义文件的MIME类型是检测为应用程序/八位字节流。如果我的一个朋友送与苹果的邮件的桌面软件,它被检测为文本/ XML(这将是很好)。而在其他邮件客户端,进化,MIME类型是文本/纯...

The problem is that our custom file are not detected the same way between mail clients. For example, if I send to myself with the gmail webpage our custom file, the mime-type is detect as application/octet-stream. If a friend of mine send with apple mail desktop software, it is detected as a text/xml (which would be nice). And on another mail client, Evolution, the mime-type is text/plain...

我们的应用程序无法处理所有这些类型!否则,它会被提议为每类型的附件...

Our application can't handle all those types ! Otherwise, it would be proposed for every type of attachment...

有什么解决方案吗?

推荐答案

解决方案与自定义扩展与Gmail中测试打开的文件; 4.2,4.2的Gmail,谷歌驱动器和文件浏览器

Solution to open file with custom extension tested with gmail < 4.2, gmail 4.2, Google Drive and file browser

code发送文件:

sendIntent.setType("application/calc1");

意图过滤器:

Intent-filter :

           <!-- 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>

这篇关于Gmail附件和自定义扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆