【问题标题】:Open custom file extension with Flutter App使用 Flutter App 打开自定义文件扩展名
【发布时间】:2020-12-05 21:27:02
【问题描述】:

如何将自定义文件扩展名 (.foo) 分配(或关联)给 FlutterApp (BarBaz),然后任何时候用户从文件管理器中选择文件,对话框都会显示此应用程序以打开文件。 后来我的应用程序可以在其中管理这个文件,并处理它的内容。

就像一个音频播放器,将音频文件关联到它,然后打开它。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    我尝试了很多变体like this,但都没有奏效。 几天后,我找到并尝试了对我有帮助的this one

    所以,我通过将此代码添加到我的 /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>
    

    【讨论】:

      猜你喜欢
      • 2019-12-11
      • 2019-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      相关资源
      最近更新 更多