-
SYNTAX:
-
<data android:scheme="string" android:host="string" android:port="string" android:path="string" android:pathPattern="string" android:pathPrefix="string" android:mimeType="string" />
CONTAINED IN:
-
<intent-filter>
DESCRIPTION:
-
Adds a data specification to an intent filter. The specification can be just a data type (the
mimeType
attribute), just a URI, or both a data type and a URI. A URI is specified by separate attributes for each of its parts:<scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>]
These attributes that specify the URL format are optional, but also mutually dependent:
- If a
scheme
is not specified for the intent filter, all the other URI attributes are ignored. - If a
host
is not specified for the filter, theport
attribute and all the path attributes are ignored.
All the
<data>
elements contained within the same<intent-filter>
element contribute to the same filter. So, for example, the following filter specification,<intent-filter . . . > <data android:scheme="something" android:host="project.example.com" /> . . . </intent-filter>
is equivalent to this one:
<intent-filter . . . > <data android:scheme="something" /> <data android:host="project.example.com" /> . . . </intent-filter>
You can place any number of
<data>
elements inside an<intent-filter>
to give it multiple data options. None of its attributes have default values.Information on how intent filters work, including the rules for how Intent objects are matched against filters, can be found in another document, Intents and Intent Filters. See also the Intent Filters section in the manifest file overview.
ATTRIBUTES:
- If a
-
-
The scheme part of a URI. This is the minimal essential attribute for specifying a URI; at least one
scheme
attribute must be set for the filter, or none of the other URI attributes are meaningful.A scheme is specified without the trailing colon (for example,
http
, rather thanhttp:
).If the filter has a data type set (the
mimeType
attribute) but no scheme, thecontent:
andfile:
schemes are assumed.Note: Scheme matching in the Android framework is case-sensitive, unlike the RFC. As a result, you should always specify schemes using lowercase letters.
-
The host part of a URI authority. This attribute is meaningless unless a
scheme
attribute is also specified for the filter.Note: host name matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should always specify host names using lowercase letters.
-
The port part of a URI authority. This attribute is meaningful only if the
scheme
andhost
attributes are also specified for the filter. -
The path part of a URI which must begin with a /. The
path
attribute specifies a complete path that is matched against the complete path in an Intent object. ThepathPrefix
attribute specifies a partial path that is matched against only the initial part of the path in the Intent object. ThepathPattern
attribute specifies a complete path that is matched against the complete path in the Intent object, but it can contain the following wildcards:- An asterisk ('
*
') matches a sequence of 0 to many occurrences of the immediately preceding character. - A period followed by an asterisk ("
.*
") matches any sequence of 0 to many characters.
Because '
\
' is used as an escape character when the string is read from XML (before it is parsed as a pattern), you will need to double-escape: For example, a literal '*
' would be written as "\\*
" and a literal '\
' would be written as "\\\\
". This is basically the same as what you would need to write if constructing the string in Java code.For more information on these three types of patterns, see the descriptions of
PATTERN_LITERAL
,PATTERN_PREFIX
, andPATTERN_SIMPLE_GLOB
in thePatternMatcher
class.These attributes are meaningful only if the
scheme
andhost
attributes are also specified for the filter. - An asterisk ('
-
A MIME media type, such as
image/jpeg
oraudio/mpeg4-generic
. The subtype can be the asterisk wildcard (*
) to indicate that any subtype matches.It's common for an intent filter to declare a
<data>
that includes only theandroid:mimeType
attribute.Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types. As a result, you should always specify MIME types using lowercase letters.
android:scheme
android:host
android:port
android:path
android:pathPrefix
android:pathPattern
android:mimeType
INTRODUCED IN:
-
The scheme part of a URI. This is the minimal essential attribute for specifying a URI; at least one
- API Level 1 SEE ALSO:
-
<action>
<category>
-
-
-
句法:
-
<data android: scheme = " string " android: host = " string " android: port = " string " android: path = " string " android: pathPattern = " string " android: pathPrefix = " string " android: mimeType = " string " />
包含在:
-
<意图过滤器>
描述:
-
添加一个数据规范的意图过滤器。该规范可以只是一个数据类型(
mime类型
属性),只是一个URI,或两者的数据类型和URI。一个URI是由它的每个部分分别指定属性:<方案>:// <主机>:<端口> [<路径> | <pathPrefix> | <pathPattern>]
指定URL格式这些属性是可选的,但也是相互依存:
所有
<数据>
包含在同一范围内的元素<意图过滤器>
元素提供相同的过滤器。因此,例如,下面的过滤器规格,<意图过滤器。。。> <数据 的android:计划= “东西” 机器人:主机= “project.example.com” /> 。。。 </意图过滤器>
相当于这一个:
<意图过滤器。。。> <数据 的android:计划= “东西” /> <数据 机器人:主机= “project.example.com” /> 。。。 </意图过滤器>
您可以将任意数量的
<数据>
内部元素<意向过滤器>
给它的多个数据的选项。它的属性都没有默认值。如何意图过滤器的工作,包括对intent对象如何与过滤器的匹配规则的信息,可以在另一个文件中,可以找到 意图和意图过滤器。又见 意图过滤器 清单文件概述部分。
属性:
-
-
URI的方案组成部分。这是用于指定一个URI的最小必需属性; 的至少一个
方案
属性必须为过滤器进行设置,或者没有其他的URI属性是有意义。一个方案,但没有尾随冒号指定的(例如,
HTTP
,而不是HTTP:
)。如果过滤器具有数据类型集(
mime类型
属性),但没有计划,内容:
和文件:
假设方案。注:在Android框架方案的匹配是大小写敏感的,不像RFC。因此,你应该总是指定使用小写字母方案。
-
一个URI权威的主机部分。此属性是毫无意义的,除非
方案
属性也为过滤器中指定。注:在Android框架主机名匹配是大小写敏感的,不像正式的RFC。因此,你应该总是指定使用小写字母的主机名。
-
一个URI港务局一部分。此属性才有意义,如果
方案
和主机
的过滤器也被指定的属性。 -
URI的路径组成部分,必须以/开始。该
路径
属性指定打击的完整路径在一个Intent对象相匹配的完整路径。所述pathPrefix
属性指定针对仅在意图对象的路径的初始部分匹配部分路径。所述pathPattern
属性指定针对意图对象的完整路径相匹配的完整路径,但它可以包含以下通配符:- 星号(“
*
”)匹配的0到紧接在前面的字符的许多事件的序列。 - 一个时期后跟一个星号(“
*
”)匹配的0至多个字符的任意序列。
因为'
\
'作为当字符串从XML读取(之前被解析为一个模式)转义字符,则需要仔细逃生:例如,一个字面'*
'会被写成“\\ *
“与字面'\
'会被写成”\\\\
“。这基本上是一样的,你需要建造,如果在Java代码中的字符串写什么。关于这三种模式的更多信息,请参阅的说明
PATTERN_LITERAL
,PATTERN_PREFIX
和PATTERN_SIMPLE_GLOB
在PatternMatcher
类。 - 星号(“
-
MIME媒体类型,如
图像/ JPEG
或音频/ MPEG4-通用
。子类型可以是星号通配符(*
),以表示任何亚型相匹配。是很常见的一个意图过滤器来声明一个
<数据>
只包括机器人:mime类型
属性。注:在Android框架MIME类型匹配是大小写敏感的,不同于正式的RFC MIME类型。因此,你应该总是指定使用小写字母MIME类型。
机器人:方案
机器人:主机
机器人:端口
机器人:路径
的android:pathPrefix
机器人:pathPattern
机器人:mime类型
介绍了:
-
URI的方案组成部分。这是用于指定一个URI的最小必需属性; 的至少一个
- API级别1 也可以看看:
-
<操作>
<类别>
-