Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening email attachments in Android

Tags:

android

I try to open a specific email attachment type with my activity, the attachment itself is a plain text windows style ini file with the extension *.os. In the email this file is attached as "application/octet-stream". I tried the following intent-filter to catch the attachment with my activity:

         <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="http" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="https" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="content" android:host="*" android:pathPattern=".*\\.os"/>
            <data android:scheme="file" android:host="*" android:pathPattern=".*\\.os"/>
        </intent-filter>

The Email app is fetching the attachment but is then telling me "The attachment cannot be displayed". What can I do? How can I debug this?

like image 552
zehrer Avatar asked Jun 13 '10 09:06

zehrer


People also ask

Why can't I open email attachments on Android?

If you can't open email attachments that are in formats your device recognises then you can probably fix the problem by removing the email account and then adding it again. These steps apply broadly to Samsung Android devices. The steps for your specific device may vary very slightly from those below.

Why can't I open email attachments?

Unrecognized file format One of the most common reasons why you can't open an e-mail attachment is because your computer doesn't have the necessary program installed to recognize the file format.

What app do I need to open email attachments?

1: Adobe Reader. In my opinion, Adobe Reader (Figure A) is the single most important app for opening email attachments. The vast majority of the important attachments I receive are in PDF format.


1 Answers

It should simply be a file scheme, so I would eliminate the others and try with just that and include the mimeType as a wildcard (either "*" or "*/*"):

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

If that doesn't work, maybe try android.intent.action.MAIN for the action. Check the logs to see if that's giving you the details of the intent that is not matching anything.

like image 170
Ian G. Clifton Avatar answered Oct 19 '22 22:10

Ian G. Clifton