【问题标题】:Android Intent Filter pathPattern exclude urlAndroid Intent Filter pathPattern 排除 url
【发布时间】:2013-10-06 22:58:26
【问题描述】:

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

我正在尝试让我的 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>

【问题讨论】:

  • 由于pathPattern 不是一个完整的正则表达式引擎,我怀疑你想要你想要的将是可能的。
  • 我就是这么想的,希望有办法

标签: android android-intent android-manifest intentfilter


【解决方案1】:

pathPattern 更像 glob 而不是 regexp。如果你真的是指mydomain/abc,你应该可以指定android:host="mydomain.com" android:pathPattern="abc",但我猜你的意思是

匹配 mydomain.com/x

不匹配 mydomain/x/y

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

【讨论】:

  • 知道现在有没有办法实现Don't match mydomain/x/y 的想法?
猜你喜欢
  • 1970-01-01
  • 2011-03-12
  • 1970-01-01
  • 2013-06-04
  • 2017-06-21
  • 1970-01-01
  • 2014-08-16
  • 1970-01-01
  • 2019-07-27
相关资源
最近更新 更多