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