2

In my project I want to my app to open custom file extension like '.bla'

I used the following IntentFilter to do this:

 <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:scheme="content" />
            <data android:mimeType="application/*" />
            <data android:host="*" />
            <data android:pathPattern=".*" />
        </intent-filter>

This works great but the problem is my app appears in the 'open with' list for any file type -as expected, but I want it to open just my extension.

I can't use explicit extension '.bla' because it wont work if I open a bla file from WhatsApp, because the file wont have its ordinary path with the extension at the end, instead, it will be some kind like 'content://com.whatsapp.provider.media/item/03fda30df57e-c5e3a-46ea-6df67-fd23e4a3cb4fe'

so, I used the pathPattern as .* instead of something like .*\\.bla to make it work

What shall I do to solve this problem and to make my app opens only the .bla extension only

sidgate
  • 14,650
  • 11
  • 68
  • 119

0 Answers0