android - 是否可以以不区分大小写的方式匹配 intent-filter 的 pathPattern?

标签 android android-intent

我们有一个 android 应用程序可以打开某些类型的文件。我已经在 AndroidManifest.xml 文件中为每个人声明了一个 Intent 过滤器(示例扩展名:ext):

        <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" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.ext"/>

        </intent-filter>

打开诸如 myFile.ext 之类的文件时一切正常,但是如果文件名为 myFile.EXTmyFile.ExT,等等 intent-filter 似乎没有接收到它。除了在 Intent 过滤器中枚举所有可能的大写排列外,还有没有办法指定不区分大小写的匹配项?

文档 here提及数据元素的其他属性区分大小写,但没有提及 pathPattern。我尝试将不区分大小写的正则表达式的 java 指令添加到导致 "(?i).*\\.ext" 和 OR'ing multile 的模式,如 ".*\\.ext|.*\\.EXT" 但这似乎也不起作用。

如果有任何帮助或建议,我将不胜感激。

谢谢!

最佳答案

android:pathPattern 不是完整的正则表达式。它是一个“simple glob”,它只支持正则表达式可以做的一小部分。

关于android - 是否可以以不区分大小写的方式匹配 intent-filter 的 pathPattern?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15121925/

相关文章:

android - 编译时在 "null": syntax error (code 1): , 附近:INSERT INTO

java - android 使用 android 前置摄像头拍照无法正常工作

android - 使用 list 注册广播接收器

android - 应用程序崩溃 : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

java - 如何将 arraylist 数据从一个 Activity 传输到另一个 Activity ?

android - 检查Android互联网连接的完美功能,包括蓝牙锅

android - 有什么方法可以在 Android 中打开 .doc 文件?

android - 如何获取在关机和开机之间传递的警报通知

android - 在开始一个新的 Intent Activity 后使用 Toast

java - 新的 Intent (上下文,类)抛出 NullPointerException