Struct android_manifest::MetaData[][src]

pub struct MetaData {
    pub name: Option<String>,
    pub resource: Option<AnyResource>,
    pub value: Option<String>,
}
Expand 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 single Bundle object and made available to the component as the PackageItemInfo.metaData field.

Ordinary values are specified through the value attribute. However, to assign a resource ID as the value, use the resource attribute instead. For example, the following code assigns whatever value is stored in the @string/kangaroo resource to the "zoo" name:

XML Examples

<meta-data android:name="zoo" android:value="@string/kangaroo" />

On the other hand, using the resource attribute would assign "zoo" 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 the resource attribute to inform the component of its ID.

XML Syntax

<meta-data android:name="string"
           android:resource="resource specification"
           android:value="string" />

Contained in

Introduced in

API Level 1

Fields

name: Option<String>

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".

resource: Option<AnyResource>

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.

value: Option<String>

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: https://developer.android.com/guide/topics/manifest/meta-data-element#val

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.