Android的 - 匹配URL模式? [英] Android - matching a url pattern?

查看:144
本文介绍了Android的 - 匹配URL模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的活动之一拿起一个特定的URL。该模式是:

I'd like one of my activities to pick up a particular url. The pattern is:

http://www.example.com/abc123/foo/xyz789

路径组件ABC123和xyz789可以是字母数字的任何序列,长度> 1

The path components "abc123" and "xyz789" can be any sequence of alpha-numerics, length > 1.

做这在我的清单:

<activity>
  <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"
      android:host="example.com" 
      android:pathPattern="/.*/foo/.*" />

但似乎从我的域中的任何模式得到匹配,即:

but it seems that any pattern from my domain is getting matched, ie:

myexample.com
myexample.com/whatever

都得到匹配。我想也许是。*操作不工作,我期待在这里?任何帮助将是巨大的,

both get matched. I guess maybe the .* operator is not working as I expect here? Any help would be great,

感谢

http://developer.android.com/guide/topics/清单/数据element.html

推荐答案

今天我有同样的问题,我的解决办法是:

I had the same problem today, my solution was:

   <data android:pathPattern="/remotes/..*/..*"/>

使用(。*)作为替换为(+)

using (..*) as a replacement for (.+)

在原来的问题的情况下,我想,这可以工作:

In the original question's case I guess that this can work:

<data
                android:host="example.com"
                android:pathPattern="..*/foo/..*"
                android:scheme="http"/>

这篇关于Android的 - 匹配URL模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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