I'm creating an intent filter for a specific extension (.infi) for my app. It works correctly with ES file explorer & Solid explorer. However when I open the file with Samsung default file explorer (Device Galaxy Tab S2) it shows a strange message "No application to perform this action", on other device (Note 4) it tries to open the file with Adobe Reader with an error message. Here is my code from manifests file :
<activity android:name=".ImportCollections">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.infi" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.infi" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\.infi" />
<data android:host="gmail-ls" />
</intent-filter>
</activity>
For future references, I looked for another open source app implementing this feature correctly. These guys are doing a great job:
https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml
Here is my code that worked (just replace "infi" with your custom extention)
<activity
android:name=".ImportCollections"
android:launchMode="singleTask"
android:parentActivityName=".ManageCollections">
<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:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="http" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="https" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="content" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="file" />
</intent-filter>
<!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/infi" />
<data android:mimeType="application/x-infi" />
<data
android:mimeType="application/octet-stream"
android:scheme="content" />
<data
android:mimeType="application/zip"
android:scheme="content" />
</intent-filter>
</activity>