我们有一个 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.EXT
或 myFile.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/