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="#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 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"> 27 {@code <scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>]}</p> 28 29 <p> 30 These 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> 33 is 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> 35 is not specified for the filter, the {@code port} attribute and all the path attributes are ignored. 36 </ul> 37 38 <p> 39 All 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 41 the 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> 58 You 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 60 options. None of its attributes have default values. 61 </p> 62 63 <p> 64 Information on how intent filters work, including the rules for how Intent objects 65 are matched against filters, can be found in another document, 66 <a href="{@docRoot}guide/components/intents-filters.html">Intents and 67 Intent Filters</a>. See also the 68 <a href="{@docRoot}guide/topics/manifest/manifest-intro.html#ifs">Intent Filters</a> 69 section 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 77 specifying a URI; at least one {@code scheme} attribute must be set 78 for the filter, or none of the other URI attributes are meaningful. 79 80 <p> 81 A scheme is specified without the trailing colon (for example, 82 {@code http}, rather than {@code http:}). 83 </p> 84 85 <p> 86 If the filter has a data type set (the <code><a 87 href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code> 88 attribute) but no scheme, the {@code content:} and {@code file:} schemes are 89 assumed. 90 </p> 91 92 <p class="note"><strong>Note</strong>: Scheme matching in the Android framework is 93 case-sensitive, unlike the RFC. As a result, you should always specify schemes 94 using 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 99 unless a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code> attribute is also 100 specified for the filter. 101 102 <p class="note"><strong>Note</strong>: host name matching in the Android framework is 103 case-sensitive, unlike the formal RFC. As a result, you should always specify 104 host 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 110 if the <code><a href="#scheme">scheme</a></code> and 111 <code><a href="#host">host</a></code> attributes are also specified for 112 the 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 /. 119 The {@code path} attribute specifies a complete 120 path that is matched against the complete path in an Intent object. The 121 {@code pathPrefix} attribute specifies a partial path that is matched against 122 only the initial part of the path in the Intent object. The {@code pathPattern} 123 attribute specifies a complete path that is matched against the complete path 124 in 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 128 the immediately preceding character.</li> 129 130 <li>A period followed by an asterisk ("{@code .*}") matches any sequence of 131 0 to many characters.</li> 132 </ul> 133 134 <p> 135 Because '{@code \}' is used as an escape character when the string is read 136 from XML (before it is parsed as a pattern), you will need to double-escape: 137 For example, a literal '{@code *}' would be written as "{@code \\*}" and a 138 literal '{@code \}' would be written as "{@code \\\\}". This is basically 139 the same as what you would need to write if constructing the string in Java code. 140 </p> 141 142 <p> 143 For 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> 152 attributes 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}. 157 The subtype can be the asterisk wildcard ({@code *}) to indicate that any 158 subtype matches. 159 160 <p>It's common for an intent filter to declare a {@code <data>} that includes 161 only the {@code android:mimeType} attribute.</p> 162 163 164 <p class="note"><strong>Note</strong>: MIME type matching in the Android framework is 165 case-sensitive, unlike formal RFC MIME types. As a result, you should always 166 specify 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"><action></a></code> 177 <br/><code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code></dd> 178 179 </dl> 180