Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail attachment and custom extension

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.

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.

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

Is there any solution for this ?

like image 426
NitroG42 Avatar asked Jun 10 '11 08:06

NitroG42


People also ask

How do I change my attachment opening settings in Gmail?

Scroll down to find Gmail and click on it. Scroll down to Advanced settings and click on it. Scroll down to Attachment compliance and hover on it and to see configure option and click on it. Select the messages that you want to affect.

What are Gmail extensions?

A Gmail extension is a Google Chrome extension that directly impacts the layout/function of your Gmail dashboard/account. You can find many of the available extensions in the Chrome web store as you just saw. Gmail search in Chrome Web Store.

How do I access extensions in Gmail?

On the main page of your Gmail account, you'll see a sidebar on the right side with icons running down it — these are all your add-ons. Any new add-ons you install will display here. At the bottom, you'll see a Plus "+" button. Click that to get to the add-ons menu.


1 Answers

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

Code to send file :

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>
like image 58
Eric JOYÉ Avatar answered Sep 30 '22 14:09

Eric JOYÉ