三星文件浏览器的 Intent-filter 异常行为
Intent-filter abnormal behavior with samsung file browser
我正在为我的应用程序的特定扩展名 (.infi) 创建一个意图过滤器。它与 ES 文件资源管理器和 Solid 资源管理器一起正常工作。但是,当我使用三星默认文件浏览器(设备 Galaxy Tab S2)打开文件时,它显示一条奇怪的消息 "No application to perform this action",在其他设备(注 4)上它尝试使用 Adobe Reader 打开文件错误信息。这是清单文件中的代码:
<activity android:name=".ImportCollections">
<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:mimeType="*/*" />
<data android:pathPattern=".*\.infi" />
</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:scheme="http" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\.infi" />
</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:scheme="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\.infi" />
<data android:host="gmail-ls" />
</intent-filter>
</activity>
为了将来的参考,我寻找了另一个正确实现此功能的开源应用程序。这些家伙做得很好:
https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml
这是我的有效代码(只需将 "infi" 替换为您的自定义扩展)
<activity
android:name=".ImportCollections"
android:launchMode="singleTask"
android:parentActivityName=".ManageCollections">
<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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="http" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="https" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="content" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="file" />
</intent-filter>
<!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/infi" />
<data android:mimeType="application/x-infi" />
<data
android:mimeType="application/octet-stream"
android:scheme="content" />
<data
android:mimeType="application/zip"
android:scheme="content" />
</intent-filter>
</activity>
我正在为我的应用程序的特定扩展名 (.infi) 创建一个意图过滤器。它与 ES 文件资源管理器和 Solid 资源管理器一起正常工作。但是,当我使用三星默认文件浏览器(设备 Galaxy Tab S2)打开文件时,它显示一条奇怪的消息 "No application to perform this action",在其他设备(注 4)上它尝试使用 Adobe Reader 打开文件错误信息。这是清单文件中的代码:
<activity android:name=".ImportCollections">
<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:mimeType="*/*" />
<data android:pathPattern=".*\.infi" />
</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:scheme="http" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\.infi" />
</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:scheme="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\.infi" />
<data android:host="gmail-ls" />
</intent-filter>
</activity>
为了将来的参考,我寻找了另一个正确实现此功能的开源应用程序。这些家伙做得很好:
https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml
这是我的有效代码(只需将 "infi" 替换为您的自定义扩展)
<activity
android:name=".ImportCollections"
android:launchMode="singleTask"
android:parentActivityName=".ManageCollections">
<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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="http" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="https" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="content" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.infi"
android:scheme="file" />
</intent-filter>
<!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/infi" />
<data android:mimeType="application/x-infi" />
<data
android:mimeType="application/octet-stream"
android:scheme="content" />
<data
android:mimeType="application/zip"
android:scheme="content" />
</intent-filter>
</activity>