我正在尝试用我的应用程序截取几个不同的链接,但我在使用意图过滤器数据参数时遇到了问题。
下面是我想截取的两种类型的链接
我已经决定使用一个单独的活动来拦截这两个链接,并使用java regex来启动正确的活动。但是,如果不捕获http://www.domain.com/abc123之类的内容,我似乎无法仅捕获这两种格式
<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="www.domain.com"
android:pathPattern="/#id.*" />
</intent-filter>
这就是我目前正在尝试拦截的类型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" />
<data android:host="domain.com" />
<data android:host="www.domain.com" />
<data android:pathPrefix="/share/web" />
<data android:pathPrefix="/social/landing" />
</intent-filter>
谢谢,
发布于 2011-05-31 06:04:36
我认为pathPattern匹配的字符串是"/",而"#id...“被省略,因为它是片段的一部分。如果使用http://www.domain.com/id/abcdef123456,pathPattern可以匹配"/id/.*“,因为它是路径的一部分。
https://stackoverflow.com/questions/6179776
复制相似问题