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