开发者

Android: android:autoLink="web" does not support .me domains

I have a TextView that I set as:

android:autoLink="web"

But when I add the following text:

TextView text = (TextView) findViewById(R.id.TextView01);
        text.setText("Test\n" +
           "http://www.domain1.net\n" +
           "\n" +
           "http://www.domain2.me\n"");

Only the first domain is hotlinked, since the other 开发者_Go百科one is .me

Is there a way to specify the correct urls for autoLink ?

Thanks!


Found the problem.

I was using a 2.1 emulator, and it seems that domain was not supported back when 2.1 was released. On 2.2 the link looks fine.

I download the Android source to see how they do it and this is what I found:

    /**
 *  Regular expression to match all IANA top-level domains for WEB_URL.
 *  List accurate as of 2010/02/05.  List taken from:
 *  http://data.iana.org/TLD/tlds-alpha-by-domain.txt
 *  This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
 */
public static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL =
    "(?:"
    + "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
    + "|(?:biz|b[abdefghijmnorstvwyz])"
    + "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"
    + "|d[ejkmoz]"
    + "|(?:edu|e[cegrstu])"
    + "|f[ijkmor]"
    + "|(?:gov|g[abdefghilmnpqrstuwy])"
    + "|h[kmnrtu]"
    + "|(?:info|int|i[delmnoqrst])"
    + "|(?:jobs|j[emop])"
    + "|k[eghimnprwyz]"
    + "|l[abcikrstuvy]"
    + "|(?:mil|mobi|museum|m[acdeghklmnopqrstuvwxyz])"
    + "|(?:name|net|n[acefgilopruz])"
    + "|(?:org|om)"
    + "|(?:pro|p[aefghklmnrstwy])"
    + "|qa"
    + "|r[eosuw]"
    + "|s[abcdeghijklmnortuvyz]"
    + "|(?:tel|travel|t[cdfghjklmnoprtvwz])"
    + "|u[agksyz]"
    + "|v[aceginu]"
    + "|w[fs]"
    + "|(?:xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-80akhbyknj4f|xn\\-\\-9t4b11yi5a|xn\\-\\-deba0ad|xn\\-\\-g6w251d|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-zckzah)"
    + "|y[etu]"
    + "|z[amw]))";

So it seems on each release GOOGLE updates from iana the latest domains


Your code is right only problem with your url "http://www.domain2.me\n", it should be valid DNS name e.g. .com/.net etc instead of .me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜