---
title: "URI数据匹配"
author: "rayloo"
date: "2011-04-06T16:21:00Z"
tags: []
slug: "uri"
draft: false
lastmod: "2011-04-06T16:21:00Z"
id: 1008819
url: "https://rayloo.iteye.com/blog/1008819"
---

一个 Intent 可以通过 URI 携带外部数据给目标组件。在 &lt;intent-filter &gt;节点中，通过 &lt;data/&gt;节点匹配外部数据。

mimeType 属性指定携带外部数据的数据类型，scheme 指定协议，host、port、path 指定数据的位置、端口、和路径。如下：

如果在 Intent Filter 中指定了这些属性，那么只有所有的属性都匹配成功时 URI 数据匹配才会成功。

该例子中通过String.format("&lt;a href=\\"%s://%s/$1\\"&gt;$1&lt;/a&gt;", WIKI\_AUTHORITY, WIKI\_LOOKUP\_HOST)));把链接格式化成&lt;a href="wiktionary://lookup/ah"&gt;ah&lt;/a&gt;形式的,这样就可以和配置文件中的data相匹配。

&lt;!-- google\_ad\_section\_end --&gt;