<meta-data android:name="string" android:resource="resource specification" android:value="string" />
<activity>
<activity-alias>
<service>
<receiver><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:
<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.
보통 값들은 value 애트리뷰트를 통해 지정되어진다. 하지만 리소스 ID에 값을 할당하기 위해 리소스 애트리뷰트를 대신 사용하라. 예를 들어 다음의 코드는 “zoo” 이름에 @string/kangaroo 리소스 안에서 저장된 임의의 값을 지정한다.
<meta-data android:name="zoo" android:value="@string/kangaroo" />
반면에, 리소스 애트리뷰트를 사용하는 것은 “zoo” 에 리소스 안에 저장된 값이 아니라 리소스의 숫자 ID를 할당할 것이다.
<meta-data android:name="zoo" android:resource="@string/kangaroo" />
여러분이 여러 개의 별도의 <meta-data> 엔트리로써 관련 데이터를 제공하지 않는 것을 적극 권장한다. 대신에, 만약 여러분이 컴포넌트와 관련된 복잡한 데이터를 가지고 있다면, 리소스로 그것을 저장하고 그 리소스 ID의 컴포넌트를 알려주기 위해 resource 애트리뷰트를 사용하라.
android:namecom.example.project.activity.fred".android:resourceBundle.getInt() method.android:value| Type | Bundle method |
|---|---|
String value, using double backslashes (\\) to escape characters
such as "\\n" and "\\uxxxxx" for a Unicode character. |
getString() |
Integer value, such as "100" |
getInt() |
Boolean value, either "true" or "false" |
getBoolean() |
Color value, in the form "#rgb", "#argb",
"#rrggbb", or "#aarrggbb" |
getString() |
Float value, such as "1.23" |
getFloat() |
| 타입 | Bundle 메쏘드 |
|---|---|
| 유니코드 문자를 위한 “\\n” 와 “\\uxxxxx” 같은 이스케이프(escape) 캐릭터에 더블 백슬래시(\\)를 사용하는 문자열 값. | getString() |
| “100”같은 정수(integer) 값. | getInt() |
| “참(true)” 또는 “거짓(false)” 중 하나인 불리언 값. | getBoolean() |
| “#rgb”,“#argb”,“#rrggbb” 또는 “#aarrggbb”형식의 컬러 값. | getString() |
| “1.23” 같은 부동소수점 값, | getFloat() |