我希望我的一项 Activity 能够获取特定的网址。模式是:
http://www.example.com/abc123/foo/xyz789
路径组件“abc123”和“xyz789”可以是任意字母数字序列,长度> 1。
在我的 list 中这样做:
<activity>
<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="example.com"
android:pathPattern="/.*/foo/.*" />
但似乎我域中的任何模式都在匹配,即:
myexample.com
myexample.com/whatever
两者都匹配。我想也许 .* 运算符没有像我期望的那样工作?任何帮助都会很棒,
谢谢
http://developer.android.com/guide/topics/manifest/data-element.html
最佳答案
我今天也遇到了同样的问题,我的解决方法是:
<data android:pathPattern="/remotes/..*/..*"/>
使用 (..*) 代替 (.+)
在原始问题的情况下,我想这可以工作:
<data
android:host="example.com"
android:pathPattern="..*/foo/..*"
android:scheme="http"/>
关于android - 匹配 <intent-filter> 中的 url 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4762251/