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