在< intent-filter>中匹配url模式 [英] Matching a url pattern in <intent-filter>
问题描述
我希望我的一项活动可以选择一个特定的网址.模式是:
I'd like one of my activities to pick up a particular url. The pattern is:
http://www.example.com/abc123/foo/xyz789
路径组件"abc123"和"xyz789"可以是任何字母数字序列,长度> 1.
The path components "abc123" and "xyz789" can be any sequence of alpha-numerics, length > 1.
在我的清单中执行此操作
Doing this in my manifest:
<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/.*" />
但是似乎我域中的任何模式都已匹配,即:
but it seems that any pattern from my domain is getting matched, ie:
myexample.com
myexample.com/whatever
都匹配.我想也许.*运算符无法按我期望的那样工作?任何帮助都会很棒,
both get matched. I guess maybe the .* operator is not working as I expect here? Any help would be great,
谢谢
http://developer.android.com/guide/topics/manifest/data-element.html
推荐答案
我今天遇到了同样的问题,我的解决方法是:
I had the same problem today, my solution was:
<data android:pathPattern="/remotes/..*/..*"/>
使用(.. *)代替(.+)
using (..*) as a replacement for (.+)
在原始问题的情况下,我认为这可以解决问题:
In the original question's case I guess that this can work:
<data
android:host="example.com"
android:pathPattern="..*/foo/..*"
android:scheme="http"/>
这篇关于在< intent-filter>中匹配url模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!