Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:
모든 애플리케이션은 그것의 루트 디렉토리에 AndroidManifest.xml 파일(정확하게 그 이름을 가짐)이 있어야만 한다. 매니페스트는 안드로이드 시스템에 애플리케이션에 대한 필수적인 정보를 제공하며, 시스템은 애플리케이션의 코드 중 어떤 것을 실행할 수 있기 전에 그 정보를 가져야 한다. 그 중에서도 특히 매니페스트는 다음과 같은 것들을 한다.
Intent messages they can handle). These declarations let the Android system
know what the components are and under what conditions they can be launched.Instrumentation classes that provide
profiling and other information as the application is running. These declarations
are present in the manifest only while the application is being developed and
tested; they're removed before the application is published.The diagram below shows the general structure of the manifest file and every element that it can contain. Each element, along with all of its attributes, is documented in full in a separate file. To view detailed information about any element, click on the element name in the diagram, in the alphabetical list of elements that follows the diagram, or on any other mention of the element name.
아래의 다이어그램은 매니페스트 파일의 일반적인 구조와 그것이 포함할 수 있는 모든 엘리먼트를 보여준다. 엘리먼트의 모든 애트리뷰트와 함께 각각의 엘리먼트들이 별도의 파일로 전부 문서화되어 있다. 어떤 엘리먼트에 대한 상세한 정보를 보기 위해서는, 아래 다이어그램 다음에 오는 알파벳 순서의 엘리먼트 리스트에 있는 엘리먼트 이름, 또는 엘리먼트 이름에 대한 또 다른 언급들을 살펴보라.
<?xml version="1.0" encoding="utf-8"?> <manifest> <uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <application> <activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity> <activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias> <service> <intent-filter> . . . </intent-filter> <meta-data/> </service> <receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver> <provider> <grant-uri-permission /> <path-permission /> <meta-data /> </provider> <uses-library /> </application> </manifest>
All the elements that can appear in the manifest file are listed below in alphabetical order. These are the only legal elements; you cannot add your own elements or attributes.
매니페스트 파일에서 나타날 수 있는 모든 엘리먼트는 알파벳 순서로 아래에 나열되어 있다. 이것들이 유일하게 허용되는 엘리먼트들이다. 여러분 자신의 엘리먼트 또는 애트리뷰트를 추가할 수는 없다.
<action>
<activity>
<activity-alias>
<application>
<category>
<data>
<grant-uri-permission>
<instrumentation>
<intent-filter>
<manifest>
<meta-data>
<path-permission />
<permission>
<permission-group>
<permission-tree>
<provider>
<receiver>
<service>
<supports-screens>
<uses-configuration>
<uses-feature>
<uses-library>
<uses-permission>
<uses-sdk>
Some conventions and rules apply generally to all elements and attributes in the manifest:
약간의 규약과 규칙이 매니페스트 안의 모든 엘리먼트와 애트리뷰트에 일반적으로 적용된다.
<manifest> and
<application>
elements are required, they each must be present and can occur only once.
Most of the others can occur many times or not at all although at
least some of them must be present for the manifest to accomplish anything
meaningful.
If an element contains anything at all, it contains other elements. All values are set through attributes, not as character data within an element.
Elements at the same level are generally not ordered. For example,
<activity>,
<provider>, and
<service>
elements can be intermixed in any sequence. (An
<activity-alias>
element is the exception to this rule: It must follow the
<activity>
it is an alias for.)
Except for some attributes of the root
<manifest>
element, all attribute names begin with an android: prefix
for example, android:alwaysRetainTaskState. Because the prefix is
universal, the documentation generally omits it when referring to attributes
by name.
<application>
element) and its principal components activities
(<activity>),
services
(<service>),
broadcast receivers
(<receiver>),
and content providers
(<provider>).
If you define a subclass, as you almost always would for the component classes
(Activity, Service,
BroadcastReceiver, and ContentProvider),
the subclass is declared through a name attribute. The name must include
the full package designation.
For example, an Service subclass might be declared as follows:
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the
string is appended to the application's package name (as specified by the
<manifest>
element's
package
attribute). The following assignment is the same as the one above:
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
<intent-filter . . . >
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.INSERT" />
<action android:name="android.intent.action.DELETE" />
. . .
</intent-filter>
@[package:]type:name
where the package name can be omitted if the resource is in the same package as the application, type is a type of resource such as "string" or "drawable" and name is the name that identifies the specific resource. For example:
<activity android:icon="@drawable/smallPic" . . . >
Values from a theme are expressed in a similar manner, but with an initial '?'
rather than '@':
?[package:]type:name
\\')
must be used to escape characters for example, '\\n' for
a newline or '\\uxxxx' for a Unicode character.만약 엘리먼트가 무언가를 포함한다면, 그것은 다른 엘리먼트를 포함한다. 모든 값은 그 엘리먼트 안의 CDATA(character data)가 아닌, 애트리뷰트를 통해 설정된다.
동일한 레벨에 있는 엘리먼트는 일반적으로 순서가 없다. 예를 들어 <activity>, <provider> 그리고 <service> 엘리먼트는 어떤 어떤 순서로든 섞일 수 있다(<activity-alias> 엘리먼트는 이 규칙에 대해 예외다. 그것은 앨리어스(alias) 하는 <activity> 뒤에 있어야 한다).
루트 <manifest> 엘리먼트의 몇 개의 애트리뷰트를 제외하고, 모든 애트리뷰트 이름은, 예를 들어 android:alwaysRetainTaskState와 같이 android: 접두어를 가지고 시작한다. 그 접두어가 보편적이기 때문에, 이 문서에서는 이름에 의해 애트리뷰트를 참조할 때 일반적으로 그것을 생략한다.
만약 여러분이 서브클래스를 정의한다면, 여러분은 거의 항상 컴포넌트 클래스(액티비티, 서비스, 브로드캐스트 리시버, 그리고 컨텐트 프로바이더)에 대한 것일 것이고, 그 서브클래스는 name 애트리뷰트를 통해 선언된다. 그 name은 전체 패키지 이름을 포함해야 한다. 예를 들어 서비스 서브클래스는 다음과 같이 선언될 수 있다.
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
하지만 약칭으로 만약 문자열의 첫 번째 문자가 마침표라면, 그 문자열은 애플리케이션의 패키지 이름에게 덧붙여진다(<manifest> 엘리먼트의 package 애트리뷰트에 의해 지정된 대로). 아래에 나오는 선언은 위에 있는 것과 같은 것이다.
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
컴포넌트를 시작할 때 안드로이드는 지명된 서브클래스의 인스턴스를 생성한다. 만약 서브클래스가 지정되지 않았다면, 그것은 베이스 클래스의 인스턴스를 생성한다.
<intent-filter . . . >
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.INSERT" />
<action android:name="android.intent.action.DELETE" />
. . .
</intent-filter>
@[package:]type:name
그곳에서 패키지 이름은 만약 그 리소스가 그 애플리케이션과 같은 패키지에 있다면 생략될 수 있다. 타입은 “string” 또는 “drawable” 과 같은 리소스의 타입이며, name은 특정 리소스를 구분하는 이름이다. 예를 들어 다음과 같다.
<activity android:icon="@drawable/smallPic" . . . >
테마 값도 비슷한 방법으로 표현된다. 그러나 이니셜 ‘@’가 아닌 ‘?’를 가진다.
?[package:]type:name
The following sections describe how some Android features are reflected in the manifest file.
다음의 섹션은 몇가지 안드로이드 특징들이 매니페스트 파일에 어떻게 반영되어 있는지를 기술한다.
The core components of an application (its activities, services, and broadcast
receivers) are activated by intents. An intent is a
bundle of information (an Intent object) describing a
desired action including the data to be acted upon, the category of
component that should perform the action, and other pertinent instructions.
Android locates an appropriate component to respond to the intent, launches
a new instance of the component if one is needed, and passes it the
Intent object.
애플리케이션의 핵심 컴포넌트(그것의 액티비티, 서비스, 그리고 브로드캐스트 리시버)는 인텐트에 의해 활성화된다. 인텐트는 원하는 액션을 설명하는 정보의 묶음(인텐트 오브젝트)이다. 그것은 그것에서 다루어져야 하는 데이터, 액션을 수행해야 하는 컴포넌트의 카테고리, 그리고 다른 관련된 명령들을 포함한다. 안드로이드는 인텐트에 응답하는 적절한 컴포넌트를 찾는다. 만약 신규 인스턴스가 필요하다면 컴포넌트의 신규 인스턴스를 런치하며, 그것에 인텐트 오브젝트를 전달한다.
Components advertise their capabilities the kinds of intents they can
respond to through intent filters. Since the Android system
must learn which intents a component can handle before it launches the component,
intent filters are specified in the manifest as
<intent-filter>
elements. A component may have any number of filters, each one describing
a different capability.
컴포넌트들은 인텐트 필터를 통해 그것들의 기능을 - 그것들이 응답할 수 있는 인텐트들의 종류 - 통지한다. 안드로이드 시스템은 컴포넌트를 런치하기 전에 컴포넌트가 취급할 수 있는 인텐트가 어떤 것인가를 알아야 하기 때문에, 인텐트 필터는 <intent-filter> 엘리먼트로써 매니페스트 안에 지정되어진다. 컴포넌트는 몇 개의 필터든 가질 수 있으며, 그것들 각각은 다른 기능을 기술한다.
An intent that explicitly names a target component will activate that component; the filter doesn't play a role. But an intent that doesn't specify a target by name can activate a component only if it can pass through one of the component's filters.
명시적으로explicitly 타겟 컴포넌트를 지명하는 인텐트는 그 컴포넌트를 활성화할 것이다; 그 필터는 역할을 담당하지 않는다. 그러나 이름에 의해 타겟을 지정하지 않은 인텐트는 오직 그것이 해당 컴포넌트의 필터들 중 하나를 통과했을 때만 컴포넌트를 활성화할 수 있다.
For information on how Intent objects are tested against intent filters, see a separate document, Intents and Intent Filters.
인텐트 오브젝트가 인텐트 필터에 대해 어떻게 테스트되는가에 대한 정보에 대해서는 5장. “인텐트와 인텐트 필터”를 보라.
A number of elements have icon and label attributes for a
small icon and a text label that can be displayed to users. Some also have a
description attribute for longer explanatory text that can also be
shown on-screen. For example, the
<permission>
element has all three of these attributes, so that when the user is asked whether
to grant the permission to an application that has requested it, an icon representing
the permission, the name of the permission, and a description of what it
entails can all be presented to the user.
다수의 엘리먼트들은 사용자에게 표시될 작은 아이콘과 텍스트 라벨을 위한 icon과 label 애트리뷰트를 가진다. 일부는 또한 스크린 상에 보여질 수 있는 더 긴 설명적인 텍스트를 위한 description 애트리뷰트를 가진다. 예를 들어 <permission> 엘리먼트는 그것을 요구했던 애플리케이션에게 퍼미션을 부여할 지 여부를 사용자에게 물을 때, 퍼미션을 나타내는 icon, 퍼미션의 name, 그리고 그것이 일으킬 수 있는 것에 대한 description이 사용자에게 모두 표시될 수 있도록 이러한 세 가지 애트리뷰트 모두를 가진다.
In every case, the icon and label set in a containing element become the default
icon and label settings for all of the container's subelements.
Thus, the icon and label set in the
<application>
element are the default icon and label for each of the application's components.
Similarly, the icon and label set for a component for example, an
<activity>
element are the default settings for each of the component's
<intent-filter>
elements. If an
<application>
element sets a label, but an activity and its intent filter do not,
the application label is treated as the label for both the activity and
the intent filter.
모든 경우에 있어서, 어떤 것을 포함하고 있는 엘리먼트에 있는 icon과 label 집합set은 그 컨테이너의 서브엘리먼트들 모두에 대한 디폴트 icon과 label 설정이 될 수 있다. 따라서, <application> 엘리먼트에서의 icon과 label 집합set은 애플리케이션의 컴포넌트들 각각에 대한 디폴트 icon과 label이다. 비슷하게 하나의 컴포넌트, 예를 들어 하나의 <activity> 엘리먼트에 대한 icon과 label 집합set은 그 컴포넌트의 <intent-filter> 엘리먼트에 대한 디폴트 설정이다. 만약 애플리케이션이 하나의 label을 설정하지만 액티비티와 그것의 인텐트 필터는 label을 설정하지 않는다면, 그 애플리케이션 label은 액티비티와 그 인텐트 필터 모두에 대한 label로써 취급되어진다.
The icon and label set for an intent filter are used to represent a component
whenever the component is presented to the user as fulfilling the function
advertised by the filter. For example, a filter with
"android.intent.action.MAIN" and
"android.intent.category.LAUNCHER" settings advertises an activity
as one that initiates an application that is, as
one that should be displayed in the application launcher. The icon and label
set in the filter are therefore the ones displayed in the launcher.
인텐트 필터에 대한 icon과 label 집합set은 컴포넌트가 사용자에게 제공될 때마다 컴포넌트가 필터에 의해 통보된 기능을 수행한다는 것을 나타내기 위해 사용된다. 예를 들어 “android.intent.action.MAIN”와 “android.intent.category.LAUNCHER” 설정을 가지는 필터는 그것이 애플리케이션을 시작시키는 액티비티, 즉 그것이 애플리케이션 런처에 표시되어져야 하는 액티비티임을 공표한다. 그러므로 그 필터 안의 icon과 label 집합set은 런처에서 보여지는 것들이 된다.
A permission is a restriction limiting access to a part of the code or to data on the device. The limitation is imposed to protect critical data and code that could be misused to distort or damage the user experience.
퍼미션은 코드의 일부나 디바이스 상의 데이터에 대한 접근을 제한하는 제약이다. 그 제한은 사용자 경험을 왜곡하거나 훼손시키기 위해 악용될 수 있는 중요한 데이터와 코드를 보호하기 위해 부과된다.
Each permission is identified by a unique label. Often the label indicates the action that's restricted. For example, here are some permissions defined by Android:
각 퍼미션은 하나의 고유한 label에 의해 구분된다. 종종 label은 제약된 액션을 가리킨다. 예를 들어 안드로이드에 의해 정의된 약간의 퍼미션이 여기 있다:
android.permission.CALL_EMERGENCY_NUMBERS
android.permission.READ_OWNER_DATA
android.permission.SET_WALLPAPER
android.permission.DEVICE_POWER
android.permission.CALL_EMERGENCY_NUMBERS android.permission.READ_OWNER_DATA android.permission.SET_WALLPAPER android.permission.DEVICE_POWER
A feature can be protected by at most one permission.
하나의 기능은 많아야 하나의 퍼미션에 의해 보호될 수 있다.
If an application needs access to a feature protected by a permission,
it must declare that it requires that permission with a
<uses-permission>
element in the manifest. Then, when the application is installed on
the device, the installer determines whether or not to grant the requested
permission by checking the authorities that signed the application's
certificates and, in some cases, asking the user.
If the permission is granted, the application is able to use the protected
features. If not, its attempts to access those features will simply fail
without any notification to the user.
애플리케이션이 퍼미션에 의해 보호된 기능에 접근을 필요로 한다면, 그것은 매니페스트 안에 <uses-permission> 엘리먼트를 가지고 그 퍼미션을 필요로 한다는 것을 선언해야 한다. 그런 다음에, 애플리케이션이 디바이에서 설치될 때 인스톨러installer는 애플리케이션의 인증서를 사인한 당국authorities을 체크하고, 그리고 어떤 경우에는 사용자에게 물어봄으로써 요청된 퍼미션에 대한 부여 여부를 결정한다. 만약 퍼미션이 부여된다면, 애플리케이션은 보호된 기능을 사용할 수 있다. 만일 그렇지 않다면, 그러한 기능에 접근하고자 하는 시도는 사용자에게 어떤 통보도 없이 간단하게 실패할 것이다.
An application can also protect its own components (activities, services,
broadcast receivers, and content providers) with permissions. It can employ
any of the permissions defined by Android (listed in
android.Manifest.permission) or declared
by other applications. Or it can define its own. A new permission is declared
with the
<permission>
element. For example, an activity could be protected as follows:
애플리케이션은 또한 그것 자신의 컴포넌트(액티비티, 서비스, 브로드캐스트 리시버, 그리고 컨텐트 프로바이더)들을 퍼미션을 가지고 보호할 수 있다. 그것은 (android.Manifest.permission에서 나열된) 안드로이드에 의해 정의되거나 또는 다른 애플리케이션에 의해 선언된 퍼미션들 중 일부를 이용할 수 있다. 또는 그것은 그것 자신의 퍼미션을 정의할 수 있다. 새로운 퍼미션은 <permission> 엘리먼트를 사용해서 선언된다. 예를 들어 액티비티는 다음과 같이 보호될 수 있다:
<manifest . . . >
<permission android:name="com.example.project.DEBIT_ACCT" . . . />
. . .
<application . . .>
<activity android:name="com.example.project.FreneticActivity"
android:permission="com.example.project.DEBIT_ACCT"
. . . >
. . .
</activity>
</application>
. . .
<uses-permission android:name="com.example.project.DEBIT_ACCT" />
. . .
</manifest>
Note that, in this example, the DEBIT_ACCT permission is not only
declared with the
<permission>
element, its use is also requested with the
<uses-permission>
element. Its use must be requested in order for other components of the
application to launch the protected activity, even though the protection
is imposed by the application itself.
이 예제에서, DEBIT_ACCT 퍼미션은 <permission> 엘리먼트를 가지고 선언되었을 뿐만 아니라, 그것의 사용 또한 <uses-permission> 엘리먼트를 가지고 요청된다는 것에 주의하라. 그 퍼미션이 애플리케이션 스스로에 의해 부과되었다 하더라도, 애플리케이션의 다른 컴포넌트가 보호된 액티비티를 런치하기 위해서 그것의 사용이 요청되어야 한다.
If, in the same example, the permission attribute was set to a
permission declared elsewhere
(such as android.permission.CALL_EMERGENCY_NUMBERS, it would not
have been necessary to declare it again with a
<permission>
element. However, it would still have been necessary to request its use with
<uses-permission>.
만약 같은 예제에서, 퍼미션 애트리뷰트가 다른 어디에서 선언된 퍼미션으로 설정되었다면 (android.permission.CALL_EMERGENCY_NUMBERS와 같이), <permission> 엘리먼트를 가지고 그 퍼미션을 다시 선언하는 것은 필요하지 않다. 그러나 여전히 <uses-permission>을 사용해서 그 퍼미션의 사용을 요청하는 것이 필요하다.
The
<permission-tree>
element declares a namespace for a group of permissions that will be defined in
code. And
<permission-group>
defines a label for a set of permissions (both those declared in the manifest with
<permission>
elements and those declared elsewhere). It affects only how the permissions are
grouped when presented to the user. The
<permission-group>
element does not specify which permissions belong to the group;
it just gives the group a name. A permission is placed in the group
by assigning the group name to the
<permission>
element's
permissionGroup
attribute.
<permission-tree> 엘리먼트는 코드에서 정의될 퍼미션 그룹에 대한 네임스페이스(namespace)를 선언한다. 그리고 <permission-group>는 퍼미션(<permission> 엘리먼트를 가지고 매니페스트에서 선언된 것들과 다른 곳에서 선언된 것들 모두) 집합set에 대한 label을 정의한다. 그것은 단지 사용자에게 표시될 때, 퍼미션들이 어떻게 그룹화되는 지에만 영향을 미친다. <permission-group> 엘리먼트는 어떤 퍼미션이 그룹에 속하는지를 지정하지 않는다; 그것은 단지 그룹에 이름을 부여한다. 퍼미션은 <permission> 엘리먼트의 permissionGroup 애트리뷰트에 그룹 이름을 할당함으로써 해당 그룹 내에 배치된다.
Every application is linked against the default Android library, which includes the basic packages for building applications (with common classes such as Activity, Service, Intent, View, Button, Application, ContentProvider, and so on).
모든 애플리케이션은 애플리케이션을 만들기 위한 기본적인 패키지(액티비티, 서비스, 인텐트, 뷰, 버튼, 애플리케이션, 컨텐트프로바이더, 그리고 기타 등등과 같은 보편적 클래스들을 가짐)를 포함하는 디폴트 안드로이드 라이브러리에 링크된다.
However, some packages reside in their own libraries. If your application
uses code from any of these packages, it must explicitly asked to be linked
against them. The manifest must contain a separate
<uses-library>
element to name each of the libraries. (The library name can be found in the
documentation for the package.)
하지만 어떤 패키지들은 그들 자신의 라이브러리 내에 존재한다. 만약 여러분의 애플리케이션이 이러한 패키지들 중 어떤 것으로부터의 코드를 사용한다면, 그것은 명시적으로 그 패키지들을 링크하도록 요구해야 한다. 매니페스트는 라이브러리의 각각을 지명하는 별도의 <uses-library> 엘리먼트를 포함해야 한다(라이브러리 이름은 패키지에 대한 문서에서 찾을 수 있다).