intent-filter-element.jd revision 2a1b706ec11e53689a2f86cc8e558e74591b462a
1page.title=<intent-filter> 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"><intent-filter android:<a href="#icon">icon</a>="<i>drawable resource</i>" 9 android:<a href="#label">label</a>="<i>string resource</i>" 10 android:<a href="#priority">priority</a>="<i>integer</i>" > 11 . . . 12</intent-filter></pre></dd> 13 14<dt>contained in:</dt> 15<dd><code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code> 16<br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a></code> 17<br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a></code> 18<br/><code><a href="{@docRoot}guide/topics/manifest/receiver-element.html"><receiver></a></code></dd> 19 20<dt>must contain:</dt> 21<dd><code><a href="{@docRoot}guide/topics/manifest/action-element.html"><action></a></code></dd> 22 23<dt>can contain:</dt> 24<dd><code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code> 25<br/><code><a href="{@docRoot}guide/topics/manifest/data-element.html"><data></a></code></dd> 26 27<dt>description:</dt> 28<dd>Specifies the types of intents that an activity, service, or broadcast 29receiver can respond to. An intent filter declares the capabilities of its 30parent component — what an activity or service can do and what types 31of broadcasts a receiver can handle. It opens the component to receiving 32intents of the advertised type, while filtering out those that are not 33meaningful for the component. 34 35<p> 36Most of the contents of the filter are described by its 37<code><a href="{@docRoot}guide/topics/manifest/action-element.html"><action></a></code>, 38<code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code>, and 39<code><a href="{@docRoot}guide/topics/manifest/data-element.html"><data></a></code> subelements. 40</p> 41 42<p> 43For a more detailed discussion of filters, see the separate 44<a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents 45and Intent Filters</a> document, as well as the 46<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#ifs">Intents Filters</a> 47section in the introduction. 48</p></dd> 49 50<dt>attributes:</dt> 51<dd><dl class="attr"> 52<dt><a name="icon"></a>{@code android:icon}</dt> 53<dd>An icon that represents the parent activity, service, or broadcast 54receiver when that component is presented to the user as having the 55capability described by the filter. 56 57<p> 58This attribute must be set as a reference to a drawable resource 59containing the image definition. The default value is the icon set 60by the parent component's {@code icon} attribute. If the parent 61does not specify an icon, the default is the icon set by the 62<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element. 63</p> 64 65<p> 66For more on intent filter icons, see 67<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#iconlabel">Icons and Labels</a> 68in the introduction. 69</p></dd> 70 71<dt><a name="label"></a>{@code android:label}</dt> 72<dd>A user-readable label for the parent component. This label, rather than 73the one set by the parent component, is used when the component is presented 74to the user as having the capability described by the filter. 75 76<p> 77The label should be set as a reference to a string resource, so that 78it can be localized like other strings in the user interface. 79However, as a convenience while you're developing the application, 80it can also be set as a raw string. 81</p> 82 83<p> 84The default value is the label set by the parent component. If the 85parent does not specify a label, the default is the label set by the 86<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element's 87<code><a href="{@docRoot}guide/topics/manifest/application-element.html#label"> label</a></code> attribute. 88</p> 89 90<p> 91For more on intent filter labels, see 92<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#iconlabel">Icons and Labels</a> 93in the introduction. 94</p></dd> 95 96<dt><a name="priority"></a>{@code android:priority}</dt> 97<dd>The priority that should be given to the parent component with regard 98to handling intents of the type described by the filter. This attribute has 99meaning for both activities and broadcast receivers: 100 101<ul> 102<li>It provides information about how able an activity is to respond to 103an intent that matches the filter, relative to other activities that could 104also respond to the intent. When an intent could be handled by multiple 105activities with different priorities, Android will consider only those with 106higher priority values as potential targets for the intent.</li> 107 108<li><p>It controls the order in which broadcast receivers are executed to 109receive broadcast messages. Those with higher priority 110values are called before those with lower values. (The order applies only 111to synchronous messages; it's ignored for asynchronous messages.)</p></li> 112</ul> 113 114<p> 115Use this attribute only if you really need to impose a specific order in 116which the broadcasts are received, or want to force Android to prefer 117one activity over others. 118</p> 119 120<p> 121The value must be an integer, such as "{@code 100}". Higher numbers have a 122higher priority. 123</p></dd> 124 125</dl></dd> 126 127<!-- ##api level indication## --> 128<dt>introduced in:</dt> 129<dd>API Level 1</dd> 130 131<dt>see also:</dt> 132<dd><code><a href="{@docRoot}guide/topics/manifest/action-element.html"><action></a></code> 133<br/><code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code> 134<br/><code><a href="{@docRoot}guide/topics/manifest/data-element.html"><data></a></code></dd> 135 136</dl> 137