- syntax:
<meta-data android:name="string" android:resource="resource specification" android:value="string" />
- contained in:
<activity><activity-alias><application><provider><receiver><service>- description:
- A name-value pair for an item of additional, arbitrary data that can be
supplied to the parent component. A component element can contain any
number of
<meta-data>subelements. The values from all of them are collected in a singleBundleobject and made available to the component as thePackageItemInfo.metaDatafield.Specify ordinary values through the
valueattribute. To assign a resource ID as the value, use theresourceattribute instead. For example, the following code assigns whatever value is stored in the@string/kangarooresource to thezooname:<meta-data android:name="zoo" android:value="@string/kangaroo" />
On the other hand, using the
resourceattribute assignszoothe numeric ID of the resource, not the value stored in the resource:<meta-data android:name="zoo" android:resource="@string/kangaroo" />
We highly recommend that you avoid supplying related data as multiple separate
<meta-data>entries. Instead, if you have complex data to associate with a component, store it as a resource and use theresourceattribute to inform the component of its ID. - attributes:
android:name- A unique name for the item. To keep the name unique, use a
Java-style naming convention, such as
"
com.example.project.activity.fred". android:resource- A reference to a resource. The ID of the resource is the value assigned
to the item. The ID is retrieved from the meta-data
Bundleusing theBundle.getInt()method. android:value- The value assigned to the item. The data types that can be assigned as values and the
Bundlemethods that components use to retrieve those values are listed in the following table:
Type Bundle method String: use double backslashes ( \\) to escape characters, such as\\nfor a new line and\\uxxxxxfor a Unicode charactergetString()Integer: for example, 100getInt()Boolean: either trueorfalsegetBoolean()Color: in the form #rgb,#argb,#rrggbb, or#aarrggbbgetInt()Float: for example, 1.23getFloat()
- introduced in:
- API level 1
<meta-data>
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[]]