ANDROID上wildcard宿主意图过滤器 [英] Android host intent filters on a wildcard

查看:166
本文介绍了ANDROID上wildcard宿主意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在Android中使用通配符:?主机属性

是这样的:

 机器人:主机=* site.com。
        机器人:pathPattern =*。
        机器人:路径preFIX =/ M /
        机器人:计划=HTTP/>

甚至

 机器人:主机=* *网站。
        机器人:pathPattern =*。
        机器人:路径preFIX =/ M /
        机器人:计划=HTTP/>


解决方案

是的。阅读的<一个Android的code后href=\"http://developer.android.com/reference/android/content/IntentFilter.AuthorityEntry.html#match(android.net.Uri)\"相对=nofollow> IntentFilter.AuthorityEntry.match(),我可以看到有把通配符主机的一种方式,但只有主机的开始相匹配。规则是这些:


  • 将*作为主机的第一个字符。

  • 写的主机其余部分才结束。

这将工作

 机器人:主机=* site.com
    机器人:pathPattern =*。
    机器人:计划=HTTP/&GT;

这将赶上链接:


  • www.site.com

  • site.com

  • mail.site.com

另外一个下面的将无法正常工作

 机器人:主机=* *网站。
    机器人:pathPattern =*。
    机器人:计划=HTTP/&GT;

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" />

解决方案

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" />

这篇关于ANDROID上wildcard宿主意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆