我正在尝试在应用程序中建立深层链接。路径模式是我需要支持的样子
URL:www.host.com/somestring-<2letters>/ 例如:良好的网址:www.host.com/Portland-OR/ 错误的网址:www.host.com/Portland-、www.host.com/-或,www.host.com /-,www.host.com/Por-O
因此,我有一组至少1个字符或更长的字母数字字符。然后我有一个“-”,然后是2个字符。我尝试过
<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="http" android:host="host.com" android:pathPrefix="/.*-.*/" />
</intent-filter>
我已阅读以下文档及其周围的源代码。 https://developer.android.com/reference/android/os/PatternMatcher
任何帮助将不胜感激。谢谢!
答案 0 :(得分:1)
您无法在AndroidManifest.xml
中以静态方式进行操作,但是可以通过提取<activity>
或包含<intent-filter>
的任何组件中的代码来编写自己的程序模式匹配器通过Uri
并使用正则表达式的intent.getData()
实例,或者只是便宜地用-
字符分割并检查第二部分。