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"><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>" /></pre></dd> 15 16 17<dt>contained in:</dt> 18<dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></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"><intent-filter></a></code> element contribute to 41the same filter. So, for example, the following filter specification, 42</p> 43 44<pre><intent-filter . . . > 45 <data android:scheme="something" android:host="project.example.com" /> 46 . . . 47</intent-filter></pre> 48 49<p>is equivalent to this one:</p> 50 51<pre><intent-filter . . . > 52 <data android:scheme="something" /> 53 <data android:host="project.example.com" /> 54 . . . 55</intent-filter></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"><intent-filter></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. The {@code path} attribute specifies a complete 119path that is matched against the complete path in an Intent object. The 120{@code pathPrefix} attribute specifies a partial path that is matched against 121only the initial part of the path in the Intent object. The {@code pathPattern} 122attribute specifies a complete path that is matched against the complete path 123in the Intent object, but it can contain the following wildcards: 124 125<ul> 126<li>An asterisk ('{@code *}') matches a sequence of 0 to many occurrences of 127the immediately preceding character.</li> 128 129<li>A period followed by an asterisk ("{@code .*}") matches any sequence of 1300 to many characters.</li> 131</ul> 132 133<p> 134Because '{@code \}' is used as an escape character when the string is read 135from XML (before it is parsed as a pattern), you will need to double-escape: 136For example, a literal '{@code *}' would be written as "{@code \\*}" and a 137literal '{@code \}' would be written as "{@code \\\\}". This is basically 138the same as what you would need to write if constructing the string in Java code. 139</p> 140 141<p> 142For more information on these three types of patterns, see the descriptions of 143{@link android.os.PatternMatcher#PATTERN_LITERAL}, 144{@link android.os.PatternMatcher#PATTERN_PREFIX}, and 145{@link android.os.PatternMatcher#PATTERN_SIMPLE_GLOB} in the 146{@link android.os.PatternMatcher} class. 147</p> 148 149<p>These attributes are meaningful only if the 150<code><a href="#scheme">scheme</a></code> and <code><a href="#host">host</a></code> 151attributes are also specified for the filter. 152</p></dd> 153 154<dt><a name="mime"></a>{@code android:mimeType}</dt> 155<dd>A MIME media type, such as {@code image/jpeg} or {@code audio/mpeg4-generic}. 156The subtype can be the asterisk wildcard ({@code *}) to indicate that any 157subtype matches. 158 159<p>It's common for an intent filter to declare a {@code <data>} that includes 160only the {@code android:mimeType} attribute.</p> 161 162 163<p class="note"><strong>Note</strong>: MIME type matching in the Android framework is 164case-sensitive, unlike formal RFC MIME types. As a result, you should always 165specify MIME types using lowercase letters.</p> 166</dd> 167 168</dl></dd> 169 170<!-- ##api level indication## --> 171<dt>introduced in:</dt> 172<dd>API Level 1</dd> 173 174<dt>see also:</dt> 175<dd><code><a href="{@docRoot}guide/topics/manifest/action-element.html"><action></a></code> 176<br/><code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code></dd> 177 178</dl> 179