Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android host intent filters on a wildcard

Is it possible to use wildcards on the android:host attribute ?

Something like:

        android:host="*.site.com"
        android:pathPattern=".*"
        android:pathPrefix="/m/"
        android:scheme="http" />

Or even

        android:host="*.site.*"
        android:pathPattern=".*"
        android:pathPrefix="/m/"
        android:scheme="http" />
like image 626
Dilvish5 Avatar asked Dec 13 '14 13:12

Dilvish5


1 Answers

Yes. After reading the Android code of IntentFilter.AuthorityEntry.match(), I can see that there is a way to put wildcard on host, but only to match the beginning of host. The rules are these:

  • Put * as the first character of the host.
  • Write the rest of of the host until the end.

This will work:

    android:host="*site.com"
    android:pathPattern=".*"
    android:scheme="http" />

It will catch links of:

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

On the other hand the one below won't work:

    android:host="*.site.*"
    android:pathPattern=".*"
    android:scheme="http" />
like image 59
Uriel Frankel Avatar answered Sep 19 '22 12:09

Uriel Frankel