Android主机意图过滤通配符

Dil*_*sh5 13 android android-intent

是否可以在android:host属性上使用通配符?

就像是:

        android:host="*.site.com"
        android:pathPattern=".*"
        android:pathPrefix="/m/"
        android:scheme="http" />
Run Code Online (Sandbox Code Playgroud)

甚至

        android:host="*.site.*"
        android:pathPattern=".*"
        android:pathPrefix="/m/"
        android:scheme="http" />
Run Code Online (Sandbox Code Playgroud)

Uri*_*kel 16

是.在阅读了IntentFilter.AuthorityEntry.match()的Android代码之后,我可以看到有一种方法可以在主机上放置通配符,但只能匹配主机的开头.规则如下:

  • 把*作为主持人的第一个角色.
  • 写下主机的其余部分直到结束.

这将有效:

    android:host="*site.com"
    android:pathPattern=".*"
    android:scheme="http" />
Run Code Online (Sandbox Code Playgroud)

它将捕获以下链接:

  • www.site.com
  • site.com
  • mail.site.com

另一方面,下面的那个不起作用:

    android:host="*.site.*"
    android:pathPattern=".*"
    android:scheme="http" />
Run Code Online (Sandbox Code Playgroud)

  • 这不会也会捕获 othersite.com 吗? (2认同)