Android意图过滤器pathPattern排除URL

7

不确定是否可能,但希望有人能提供解决方案。

我正在尝试让我的Android应用程序拦截形式为mydomain.com/abc的url,但不拦截mydomain.com/mp3/id。

是否可以通过pathPattern来排除某些路径?

<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="mydomain.com" />
                <data android:pathPattern="/.*" /> />
        </intent-filter>

2
由于pathPattern不是完整的正则表达式引擎,我怀疑你想要的可能不会实现。 - CommonsWare
这就是我正在考虑的,只是希望有一种方法。 - Leo
1个回答

0

pathPattern 的工作方式更像 glob 而不是 regexp。如果你真的想要匹配 mydomain/abc,你应该能够指定 android:host="mydomain.com" android:pathPattern="abc",但我猜你的意思是:

匹配 mydomain.com/x

不匹配 mydomain/x/y

我认为这是不可能的。如果有可能,那可能涉及到一些 pathPrefix 的使用。


有没有想法现在是否有一种方法来实现“不匹配mydomain/x/y”的想法? - JuiCe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接