• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=<data>
2parent.title=The AndroidManifest.xml File
3parent.link=manifest-intro.html
4@jd:body
5
6<dl class="xml">
7<dt>syntax:</dt>
8<dd><pre class="stx">&lt;data android:<a href="#scheme">scheme</a>="<i>string</i>"
9      android:<a href="#host">host</a>="<i>string</i>"
10      android:<a href="#port">port</a>="<i>string</i>"
11      android:<a href="#path">path</a>="<i>string</i>"
12      android:<a href="#path">pathPattern</a>="<i>string</i>"
13      android:<a href="#path">pathPrefix</a>="<i>string</i>"
14      android:<a href="#mime">mimeType</a>="<i>string</i>" /&gt;</pre></dd>
15
16
17<dt>contained in:</dt>
18<dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code></dd>
19
20<dt>description:</dt>
21<dd itemprop="description">Adds a data specification to an intent filter.  The specification can
22be just a data type (the <code><a href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code> attribute),
23just a URI, or both a data type and a URI.  A URI is specified by separate
24attributes for each of its parts:
25
26<p style="margin-left: 2em">
27{@code <scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>]}</p>
28
29<p>
30These attributes that specify the URL format are optional, but also mutually dependent:
31<ul>
32  <li>If a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code>
33is not specified for the intent filter, all the other URI attributes are ignored.</li>
34  <li>If a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#host">host</a></code>
35is not specified for the filter, the {@code port} attribute and all the path attributes are ignored.
36</ul>
37
38<p>
39All the {@code <data>} elements contained within the same
40<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> element contribute to
41the same filter.  So, for example, the following filter specification,
42</p>
43
44<pre>&lt;intent-filter . . . &gt;
45    &lt;data android:scheme="something" android:host="project.example.com" /&gt;
46    . . .
47&lt;/intent-filter&gt;</pre>
48
49<p>is equivalent to this one:</p>
50
51<pre>&lt;intent-filter . . . &gt;
52    &lt;data android:scheme="something" /&gt
53    &lt;data android:host="project.example.com" /&gt;
54    . . .
55&lt;/intent-filter&gt;</pre>
56
57<p>
58You can place any number of {@code <data>} elements inside an
59<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> to give it multiple data
60options.  None of its attributes have default values.
61</p>
62
63<p>
64Information on how intent filters work, including the rules for how Intent objects
65are matched against filters, can be found in another document,
66<a href="{@docRoot}guide/components/intents-filters.html">Intents and
67Intent Filters</a>.  See also the
68<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#ifs">Intent Filters</a>
69section in the manifest file overview.
70</p></dd>
71
72<dt>attributes:</dt>
73<dd><dl class="attr">
74
75<dt><a name="scheme"></a>{@code android:scheme}</dt>
76<dd>The scheme part of a URI.  This is the minimal essential attribute for
77specifying a URI; at least one {@code scheme} attribute must be set
78for the filter, or none of the other URI attributes are meaningful.
79
80<p>
81A scheme is specified without the trailing colon (for example,
82{@code http}, rather than {@code http:}).
83</p>
84
85<p>
86If the filter has a data type set (the <code><a
87href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code>
88attribute) but no scheme, the {@code content:} and {@code file:} schemes are
89assumed.
90</p>
91
92<p class="note"><strong>Note</strong>: Scheme matching in the Android framework is
93case-sensitive, unlike the RFC.  As a result, you should always specify schemes
94using lowercase letters.</p>
95</dd>
96
97<dt><a name="host"></a>{@code android:host}</dt>
98<dd>The host part of a URI authority.  This attribute is meaningless
99unless a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code> attribute is also
100specified for the filter.
101
102<p class="note"><strong>Note</strong>: host name matching in the Android framework is
103case-sensitive, unlike the formal RFC.  As a result, you should always specify
104host names using lowercase letters.</p>
105</dd>
106
107
108<dt><a name="port"></a>{@code android:port}</dt>
109<dd>The port part of a URI authority.  This attribute is meaningful only
110if the <code><a href="#scheme">scheme</a></code> and
111<code><a href="#host">host</a></code> attributes are also specified for
112the filter.</dd>
113
114
115<dt><a name="path"></a>{@code android:path}
116<br/>{@code android:pathPrefix}
117<br/>{@code android:pathPattern}</dt>
118<dd>The path part of a URI which must begin with a /.
119The {@code path} attribute specifies a complete
120path that is matched against the complete path in an Intent object.  The
121{@code pathPrefix} attribute specifies a partial path that is matched against
122only the initial part of the path in the Intent object.  The {@code pathPattern}
123attribute specifies a complete path that is matched against the complete path
124in the Intent object, but it can contain the following wildcards:
125
126<ul>
127<li>An asterisk ('{@code *}') matches a sequence of 0 to many occurrences of
128the immediately preceding character.</li>
129
130<li>A period followed by an asterisk ("{@code .*}") matches any sequence of
1310 to many characters.</li>
132</ul>
133
134<p>
135Because '{@code \}' is used as an escape character when the string is read
136from XML (before it is parsed as a pattern), you will need to double-escape:
137For example, a literal '{@code *}' would be written as "{@code \\*}" and a
138literal '{@code \}' would be written as "{@code \\\\}".  This is basically
139the same as what you would need to write if constructing the string in Java code.
140</p>
141
142<p>
143For more information on these three types of patterns, see the descriptions of
144{@link android.os.PatternMatcher#PATTERN_LITERAL},
145{@link android.os.PatternMatcher#PATTERN_PREFIX}, and
146{@link android.os.PatternMatcher#PATTERN_SIMPLE_GLOB} in the
147{@link android.os.PatternMatcher} class.
148</p>
149
150<p>These attributes are meaningful only if the
151<code><a href="#scheme">scheme</a></code> and <code><a href="#host">host</a></code>
152attributes are also specified for the filter.
153</p></dd>
154
155<dt><a name="mime"></a>{@code android:mimeType}</dt>
156<dd>A MIME media type, such as {@code image/jpeg} or {@code audio/mpeg4-generic}.
157The subtype can be the asterisk wildcard ({@code *}) to indicate that any
158subtype matches.
159
160<p>It's common for an intent filter to declare a {@code <data>} that includes
161only the {@code android:mimeType} attribute.</p>
162
163
164<p class="note"><strong>Note</strong>: MIME type matching in the Android framework is
165case-sensitive, unlike formal RFC MIME types.  As a result, you should always
166specify MIME types using lowercase letters.</p>
167</dd>
168
169</dl></dd>
170
171<!-- ##api level indication## -->
172<dt>introduced in:</dt>
173<dd>API Level 1</dd>
174
175<dt>see also:</dt>
176<dd><code><a href="{@docRoot}guide/topics/manifest/action-element.html">&lt;action&gt;</a></code>
177<br/><code><a href="{@docRoot}guide/topics/manifest/category-element.html">&lt;category&gt;</a></code></dd>
178
179</dl>
180