I have a zip file but with a custom file extension xyz. I want my app to be able to open ONLY files with the custom file extension xyz from:
Open with from the android file explorer,Share via from the android file explorer.My best shot was to just use a mime type of application/zip. However this would also open files with the file extension .zip.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/zip" />
</intent-filter>
I tried to add a <data android:pathPattern=".*\\.xyz"/>. But the problem with this is, that it will be ignored as long as I don't specify android:scheme and android:host see here.
This attribute is meaningful only if the scheme and host attributes are also specified for the filter.
As soon as I specify the scheme and host as seen in the next code segment, I can't even open any file with my App:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="*" />
<data android:scheme="*" />
<data android:mimeType="application/zip" />
<data android:pathPattern=".*\\.xyz"/>
</intent-filter>
Possible Duplicates:
Use application/octet-stream instead of application/zip. Bellow works for me:
<intent-filter tools:ignore="AppLinkUrlError"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:priority="50" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\.ext" />
<data android:pathPattern=".*\\..*\\.ext" />
<data android:pathPattern=".*\\..*\\..*\\.ext" />
</intent-filter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With