- 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 singleBundle
object and made available to the component as thePackageItemInfo.metaData
field.Specify ordinary values through the
value
attribute. However, to assign a resource ID as the value, use theresource
attribute instead. For example, the following code assigns whatever value is stored in the@string/kangaroo
resource to thezoo
name:<meta-data android:name="zoo" android:value="@string/kangaroo" />
On the other hand, using the
resource
attribute would assignzoo
the numeric ID of the resource, not the value stored in the resource:<meta-data android:name="zoo" android:resource="@string/kangaroo" />
It is highly recommended 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 theresource
attribute to inform the component of its ID. - attributes:
android:name
- A unique name for the item. To ensure that the name is unique, use a
Java-style naming convention — for example,
"
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 can be retrieved from the meta-data Bundle by the
Bundle.getInt()
method. android:value
- 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:
Type Bundle method String: Use double backslashes ( \\
) to escape characters; for example,\\n
and\\uxxxxx
for a Unicode charactergetString()
Integer: For example, 100
getInt()
Boolean: Either true
orfalse
getBoolean()
Color: In the form #rgb
,#argb
,#rrggbb
, or#aarrggbb
getInt()
Float: For example, 1.23
getFloat()
- introduced in:
- API Level 1
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 2022-11-21 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]