• 4
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

My app is supposed to handle my custom .rmc files. My users are going to receive them via email and I want my app to be able to open them but ideally open as few other filetypes that my app can't handle as possible.

I use the following intent-filter in Android with unfortunately doesn't work for opening attachemnts in gmail (gmail gives an error message that there's no app to open rmc files).

        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <action android:name="android.intent.action.VIEW"/>


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

            <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="content" android:mimeType="*/*" android:host="*" android:pathPattern=".*\\.rmc"/>
            <data android:mimeType="application/octet" />
            <data android:mimeType="application/octet-stream" />
        </intent-filter>

For comparison the following filter catches the file but catches way too much:

        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <action android:name="android.intent.action.VIEW"/>


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

            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="application/*" />
        </intent-filter>

My app is supposed to handle my custom .rmc files.

There is very little support for file extensions in Android.

I use the following intent-filter in Android with unfortunately doesn't work for opening attachemnts in gmail

There is no requirement for Gmail, or any other app, to use content Uri values that use a file extension. So, you're welcome to have that <intent-filter>, but do not assume that it will work with all email clients or any other arbitrary app.

How do I register my app in Android to open email attachments with a custom filetype?

You don't.

If the email clients sending the emails will supply a specific distinctive MIME type for your content, use that MIME type for android:mimeType. For example, if you will be sending the emails from some server, you should be able to control how the attachment is added and what MIME type it uses.

Otherwise, find some distribution mechanism for this data that uses a distinctive MIME type (e.g., download from a Web server, where you configure the server to serve your files with that MIME type). Then, use that MIME type for android:mimeType.

  • 1
Reply Report
    • Thanks, is there any way to see what mime-type gmail does use when it passes the file to me (so that I have to catch less then just application/*?
      • 1
    • @Christian: getIntent().getType() will tell you what MIME type was placed on the Intent that triggered onCreate() of your activity.