Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Custom File Type Gmail Attachment In App

I have been struggling with this for days now.

I am trying to register my activity via intent filter to open a specific custom file type with gmail.

The problem is no matter what I try, either I do not get the option to open the file or any attachment of any file type (including mine) is given the option to open with my application.

I believe the problem is that the URI supplied by gmail doesn't have any file details contained inside it.

There are plenty of people who have asked this same question however the solution to all of them never limit the intent filter to just the custom file type.

The current intent filter in my Android Manifest is the following...

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

Just to reiterate, this intent filter adds the option to open any attachment from gmail with my application.

Any help would be much appreciated

like image 918
StuStirling Avatar asked Jan 10 '13 11:01

StuStirling


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.

Why can't I see attachments in Gmail app?

Why can't I see attachments on Gmail? The messages with attachments may be collapsed behind newer messages, so you don't see the attachments, but they do show in the conversation list if you use the Default density and the paperclip icons should be visible in the list.


1 Answers

There is not necessarily a file extension on content:// Uri values pointing to files. AFAIK, Gmail does not include a file extension on theirs, and so it will not match your pathPattern. Also, host is missing the android: namespace prefix.

If the email will be sent with a distinct MIME type for your file, use that in android:mimeType and drop the remaining <data> attributes. If the email will not be sent with a distinct MIME type for your file, then AFAIK you are out of luck.

like image 58
CommonsWare Avatar answered Sep 20 '22 08:09

CommonsWare