Вопрос

I wanted a custom extension file (*.xyz) to be opened through my app. Inside the application manifest file I am writing the following:

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

After that I will install my application on the device and will send a mail containing the Sample.xyz mail as an attachment. When I try to tap on attachment in the mail client to open the attachment then it will give an error called

No app can open this attachment for viewing

Even if when I download the attachment and then try to open it then it will give an error

Can't open file

Can anyone suggest what might be going wrong ?

Это было полезно?

Решение

your filter does not match as it is not http https file and content at the same time - you will need different <intent-filter>'s for this - have a look here: https://github.com/ligi/PassAndroid/blob/master/src/main/AndroidManifest.xml and just do what I do for *.pkpass for *.xyz like so:

    <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:host="*"
            android:pathPattern=".*\\.xyz"
            android:scheme="http" />
    </intent-filter>
    <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:host="*"
            android:pathPattern=".*\\.xyz"
            android:scheme="https" />
    </intent-filter>
    <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:host="*"
            android:pathPattern=".*\\.xyz"
            android:scheme="file" />
    </intent-filter>
    <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:host="*"
            android:pathPattern=".*\\.xyz"
            android:scheme="content" />
    </intent-filter>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top