avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
564 stars 317 forks source link

How do I open a CSV file from WhatsApp? #78

Closed doomkin closed 3 years ago

doomkin commented 4 years ago

My app opens CSV files from File Explorer, but it doesn't open from WhatsApp with message: You may not have an app installed to view these files. AndroidManifest.xml:

            <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:pathPattern=".*\.csv"/>
            </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:mimeType="*/*"/>
                <data
                    android:host="*"
                    android:scheme="content"
                    android:pathPattern=".*\.csv"/>
                <data
                    android:host="*"
                    android:scheme="file"
                    android:pathPattern=".*\.csv"/>
            </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:host="*"
                    android:scheme="file"
                    android:pathPattern=".*\.csv"
                    android:mimeType="text/plain"/>
                <data
                    android:host="*"
                    android:scheme="content"
                    android:pathPattern=".*\.csv"
                    android:mimeType="text/plain"/>
            </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:host="*"
                    android:scheme="file"
                    android:pathPattern=".*\.csv"
                    android:mimeType="application/octet-stream"/>
                <data
                    android:host="*"
                    android:scheme="content"
                    android:pathPattern=".*\.csv"
                    android:mimeType="application/octet-stream"/>
            </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:host="*"
                    android:scheme="file"
                    android:pathPattern=".*\.csv"
                    android:mimeType="application/csv"/>
                <data
                    android:host="*"
                    android:scheme="content"
                    android:pathPattern=".*\.csv"
                    android:mimeType="application/csv"/>
            </intent-filter>
avioli commented 3 years ago

This package is for handling links from specific schemes or schemes+hosts, not based on mime-type or extension.

Mime-type intent-filters are meant for a different action and as far as I know file viewers/editors cannot be handled by a flutter plugin - they need to be manually configured and handled by the app developer.