Android的意图过滤的http地址 [英] Android Intent-Filter for http address

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

问题描述

我试图拦截了几个不同环节与我的应用程序,我有意向过滤器的数据参数的麻烦做到这一点。

I am trying to intercept a couple different links with my app, and I am having trouble with the intent-filter data parameters to do it.

下面是两种类型的链接,我想拦截

Here are the 2 types of links that I want to intercept

  1. http://www.domain.com/#id=abcdef123346
  2. <一个href="http://www.domain.com/social/landing/abcdef123456">http://www.domain.com/social/landing/abcdef123456
  1. http://www.domain.com/#id=abcdef123346
  2. http://www.domain.com/social/landing/abcdef123456

我已经决定有一个单独的活动来拦截这两个链接和使用Java正则表达式来启动正确的活动。不过,我似乎无法捕捉到刚刚这两个格式,无需捕捉像 http://www.domain.com/abc123

I have already decided to have a separate activity to intercept both links and use java regex to start the correct activity. However I can't seem to capture just these two formats without capturing something like http://www.domain.com/abc123

<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="www.domain.com"
                android:pathPattern="/#id.*" />
        </intent-filter>

这是我目前试图拦截1型和由于某种原因,这是行不通的。

This is what I am currently trying to intercept type 1 and for some reason it isn't working.

这个意图过滤器正确拦截型2

This intent-filter correctly intercepts type 2

<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" />
            <data android:host="domain.com" />
            <data android:host="www.domain.com" />
            <data android:pathPrefix="/share/web" />
            <data android:pathPrefix="/social/landing" />
        </intent-filter>

谢谢

推荐答案

我认为字符串pathPattern是匹配/和#ID ......被省略,因为它是片段的一部分。如果您使用 http://www.domain.com/id/abcdef123456 相反,pathPattern可以匹配/id/.*,因为它是在路径的一部分。

I think that the string that pathPattern is matching is "/", and "#id..." is omitted because it is part of the fragment. If you used http://www.domain.com/id/abcdef123456 instead, pathPattern could match "/id/.*" because it is part of the path.

这篇关于Android的意图过滤的http地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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