将某些文件扩展名与我的Android应用程序关联

dch*_*tri 8 file-extension android android-manifest

我无法将自定义文件扩展名与我正在开发的Android应用程序相关联.在我的Android清单文件中,我有以下内容:

<data android:scheme="file" android:mimeType="*/*" android:pathPattern="*.*\\.myFileExt" />
<data android:scheme="content" android:mimeType="*/*" android:pathPattern="*.*\\.myFileExt" />  
Run Code Online (Sandbox Code Playgroud)

它有点工作.让我解释.我的gmail中有一个文件(发送给我自己的文件),它有适当的扩展名,所以当我从手机的浏览器下载并单击打开时,它会正确打开我的应用程序,但是如果我探索该文件路径; 文件所在的位置,并尝试打开它,我的手机说没有应用程序可以打开此文件类型.

关于如何解决这个问题的任何想法?

Ren*_*ene 5

有些情况有点棘手,我决定使用:

    <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:mimeType="*/*" />
        <data android:pathPattern=".*\\.myFileExt" />
        <data android:host="*" />
    </intent-filter>
Run Code Online (Sandbox Code Playgroud)

这有时会失败,因为有时只使用更全局的 mime 类型(在我的情况下为 XML):

    <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="text/xml" />
    </intent-filter>
Run Code Online (Sandbox Code Playgroud)