1 page.title=<meta-data>
6 <dd><pre class="stx"><meta-data android:<a href="#nm">name</a>="<i>string</i>"
7 android:<a href="#rsrc">resource</a>="<i>resource specification</i>"
8 android:<a href="#val">value</a>="<i>string</i>" /></pre></dd>
10 <dt>contained in:</dt>
11 <dd><code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code>
12 <br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a></code>
13 <br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a></code>
14 <br/><code><a href="{@docRoot}guide/topics/manifest/receiver-element.html"><receiver></a></code></dd>
17 <dd>A name-value pair for an item of additional, arbitrary data that can
18 be supplied to the parent component. A component element can contain any
19 number of {@code <meta-data>} subelements. The values from all of
20 them are collected in a single {@link android.os.Bundle} object and made
21 available to the component as the
22 {@link android.content.pm.PackageItemInfo#metaData
23 PackageItemInfo.metaData} field.
26 Ordinary values are specified through the <code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html#value">value</a></code>
27 attribute. However, to assign a resource ID as the value, use the
28 <code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html#resource">resource</a></code> attribute instead. For example,
29 the following code assigns whatever value is stored in the {@code @string/kangaroo}
30 resource to the "{@code zoo}" name:
33 <pre><meta-data android:name="zoo" android:value="@string/kangaroo" /></pre>
36 On the other hand, using the {@code resource} attribute would assign "{@code zoo}"
37 the numeric ID of the resource, not the value stored in the resource:
40 <pre><meta-data android:name="zoo" android:resource="@string/kangaroo" /></pre>
43 It is highly recommended that you avoid supplying related data as
44 multiple separate {@code <meta-data>} entries. Instead, if you
45 have complex data to associate with a component, store it as a resource and
46 use the {@code resource} attribute to inform the component of its ID.
51 <dt><a name="nm"></a>{@code android:name}</dt>
52 <dd>A unique name for the item. To ensure that the name is unique, use a
53 Java-style naming convention — for example,
54 "{@code com.example.project.activity.fred}".</dd>
56 <dt><a name="rsrc"></a>{@code android:resource}</dt>
57 <dd>A reference to a resource. The ID of the resource is the value assigned
58 to the item. The ID can be retrieved from the meta-data Bundle by the
59 {@link android.os.Bundle#getInt Bundle.getInt()} method.</dd>
61 <dt><a name="val"></a>{@code android:value}</dt>
62 <dd>The value assigned to the item. The data types that can be assigned as values and the Bundle methods that components use to retrieve those values are listed in the following table:
67 <th>Bundle method</th>
69 <td>String value, using double backslashes ({@code \\}) to escape characters
70 — such as "{@code \\n}" and "{@code \\uxxxxx}" for a Unicode character.</td>
71 <td>{@link android.os.Bundle#getString(String) getString()}</td>
73 <td>Integer value, such as "{@code 100}"</td>
74 <td>{@link android.os.Bundle#getInt(String) getInt()}</td>
76 <td>Boolean value, either "{@code true}" or "{@code false}"</td>
77 <td>{@link android.os.Bundle#getBoolean(String) getBoolean()}</td>
79 <td>Color value, in the form "{@code #rgb}", "{@code #argb}",
80 "{@code #rrggbb}", or "{@code #aarrggbb}"</td>
81 <td>{@link android.os.Bundle#getString(String) getString()}</td>
83 <td>Float value, such as "{@code 1.23}"</td>
84 <td>{@link android.os.Bundle#getFloat(String) getFloat()}</td>
90 <!-- ##api level indication## -->
91 <dt>introduced in:</dt>