1

How can I assign (or associate) a custom file extension (.foo) to an FlutterApp (BarBaz), and then any time that the user select a file from the file manager, the dialog show this app to open the file. Later my app can manage this file inside of it, and hanlde its contents.

Like a audio player associate audio files to it, and open it.

Jorge Luis
  • 902
  • 12
  • 25

1 Answers1

1

I have tried many variations like this, but none of them worked. After few days, I found and tried this one that helped me.

So, I solved it by adding this code to my /android/app/src/main/AndroidManifest.xml:

<manifest>
    ...
    <application>
    ...
        <activity>
        ...

            <intent-filter android:priority="999">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.OPENABLE" />

                <data android:host="*" />
                <data android:mimeType="application/octet-stream" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:pathPattern=".*\\..*\\..*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:pathPattern=".*\\..*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:pathPattern=".*\\.YOUR_CUSTOM_EXTENSION" />
                <data android:scheme="content" />
            </intent-filter>

        ...
        </activity>
    </application>
</manifest>
Marco Zoratti
  • 181
  • 1
  • 3