Android 自定义pathPattern的意图过滤器
我使用此意向筛选器在我的应用程序中打开扩展名为“custom”的文件:Android 自定义pathPattern的意图过滤器,android,android-intent,android-manifest,intentfilter,Android,Android Intent,Android Manifest,Intentfilter,我使用此意向筛选器在我的应用程序中打开扩展名为“custom”的文件: <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="cont
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.custom" />
<data android:pathPattern=".*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.custom" />
</intent-filter>
但在这种情况下,它不会打开:
当从电报聊天打开文件时,它也能很好地工作
如何从任何地方打开自定义文件
UPD
我为测试添加了pdf mime类型。它可以从任何地方打开pdf文件。以下是我的意图:
- 下载文件夹(使用自定义扩展名):
Intent{act=android.Intent.action.VIEW dat=content://com.google.android.apps.nbu.files.provider/1/file:///storage/emulated/0/Download/Untitled.pdf typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain}
- 对于电报(与自定义扩展名一起使用):
Intent{act=android.Intent.action.VIEW dat=content://org.telegram.messenger.provider/media/Telegram/Telegram Documents/2_5276292126848585208.pdf typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain}
- 对于第二个映像中的下载文件夹(不适用于自定义扩展):
Intent{act=android.Intent.action.VIEW dat=content://com.google.android.apps.nbu.files.provider/2/1863 typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain}
- 从通知面板从Dowdload manager打开(不适用于自定义扩展):
Intent{act=android.Intent.action.VIEW dat=content://com.android.providers.downloads.documents/document/1508 typ=application/pdf flg=0x1300003 cmp=team.sls.testapp/.ActivityMain}
如何从任何地方打开自定义文件
无法从任何地方打开自定义文件
帮助我在我的记忆中找出原因
问题是intent
中的Uri
值没有文件扩展名
有哪些替代方案?我们可以使用标准的application/
{whatever}mime类型在应用程序中打开文件。但我们必须在文件资源管理器中选择“打开…”菜单项