<service>

syntax:
<service android:enabled=["true" | "false"]
         android:exported[="true" | "false"]
         android:icon="drawable resource"
         android:label="string resource"
         android:name="string"
         android:permission="string"
         android:process="string" >
    . . .
</service>
contained in:
<application>
can contain:
<intent-filer>
<meta-data>
description:
Declares a service (a Service subclass) as one of the application's components. Unlike activities, services lack a visual user interface. They're used to implement long-running background operations or a rich communications API that can be called by other applications.

All services must be represented by <service> elements in the manifest file. Any that are not declared there will not be seen by the system and will never be run.

애플리케이션의 컴포넌트들 중 하나로써, 서비스(Sevice 서브클래스)를 선언한다. 액티비티들과 달리, 서비스는 비쥬얼한 사용자 인터페이스가 없다. 그것은 오랫동안 실행되는 백그라운드 오퍼레이션이나, 또는 다른 애플리케이션에 의해 호출될 수 있는 풍부한 커뮤니케이션 API를 구현하기 위해 사용된다. 모든 서비스는 매니페스트 파일의 <service> 엘리먼트에 의해 표시되어야 한다. 그곳에 선언되지 않는 것은 시스템에게 보여지지 않으며, 결코 실행되지 않을 것이다.

attributes:
android:enabled
Whether or not the service can be instantiated by the system "true" if it can be, and "false" if not. The default value is "true".

The <application> element has its own enabled attribute that applies to all application components, including services. The <application> and <service> attributes must both be "true" (as they both are by default) for the service to be enabled. If either is "false", the service is disabled; it cannot be instantiated.

서비스가 시스템에 의해 인스턴스화 될 수 있는 지 여부 - 그것이 될 수 있다면 “참true” 아니라면 “거짓false”이다. 디폴트 값은 “참true”이다.

<application> 엘리먼트는, 서비스를 포함하는 모든 애플리케이션 컴포넌트에 적용되는 그것 소유의 enabled 애트리뷰트를 가진다. 서비스가 활성화 되게하기 위해서는 <application> 과 <service> 애트리뷰트 모두 (디폴트로 그것들 모두가 그렇듯이) ”참true”이어야 한다. 만일 어느 것 하나라도 “거짓false”이라면, 서비스는 비활성화 된다; 그것은 인스턴스화 될 수 없다.

android:exported
Whether or not components of other applications can invoke the service or interact with it "true" if they can, and "false" if not. When the value is "false", only components of the same application or applications with the same user ID can start the service or bind to it.

The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true".

This attribute is not the only way to limit the exposure of a service to other applications. You can also use a permission to limit the external entities that can interact with the service (see the permission attribute).

다른 애플리케이션의 컴포넌트가 서비스를 호출하거나 또는 그것과 상호작용할 수 있는 지 여부 ? 만약 그것들이 할 수 있으면 “참true” 아니라면 “거짓false”이다. 값이 “거짓false” 일 때, 동일 애플리케이션 또는 동일 유저user ID를 갖는 애플리케이션의 컴포넌트들만이 서비스를 시작하거나 또는 그것이 바인드 할 수 있다.

디폴트 값은 서비스가 인텐트 필터를 포함하는 지 여부에 따라 다르다. 아무런 필터도 없다는 것은 그것의 정확한 클래스 이름을 지정하는 것에 의해서만 호출될 수 있다는 것을 의미한다. 이것은 서비스가 애플리케이션 내부 용도를 위해서만 의도되었다는 것을 의미한다(다른 것들이 클래스 이름을 모를 것이기 때문에). 그러므로 이런 경우에 디폴트 값은 “거짓false”이다. 반면에, 최소한 하나의 필터라도 있다는 것은 서비스가 외부 사용을 위해 의도되었다는 것을 의미한다. 그러므로 디폴트 값은 “참true”이다.

이 애트리뷰트가 다른 애플리케이션에게 서비스의 노출을 제한하는 유일한 방법은 아니다. 여러분은 또한 서비스와 상호작용할 수 있는 외부 엔티티를 제한하기 위해서 퍼미션을 사용할 수 있다(permission 애트리뷰트를 보라).

android:icon
An icon representing the service. This attribute must be set as a reference to a drawable resource containing the image definition. If it is not set, the icon specified for the application as a whole is used instead (see the <application> element's icon attribute).

The service's icon whether set here or by the <application> element is also the default icon for all the service's intent filters (see the <intent-filter> element's icon attribute).

서비스를 나타내는 아이콘. 이 애트리뷰트는 이미지 정의를 포함하는 드로어블drawable 리소스에 대한 레퍼런스로써 설정되어야 한다. 그것이 설정되지 않으면, 전체 애플리케이션에 대해 지정된 아이콘이 대신 사용된다(<application> 엘리먼트의 icon 애트리뷰트를 보라).

서비스의 아이콘은 ? 여기서 설정되던 또는 <application> 엘리먼트에서 설정되던 상관없이 ? 또한 모든 서비스의 인텐트 필터에 대한 디폴트 아이콘이다(<intent-filter> 엘리먼트의 icon 애트리뷰트를 보라).

android:label
A name for the service that can be displayed to users. If this attribute is not set, the label set for the application as a whole is used instead (see the <application> element's label attribute).

The service's label whether set here or by the <application> element is also the default label for all the service's intent filters (see the <intent-filter> element's label attribute).

The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface. However, as a convenience while you're developing the application, it can also be set as a raw string.

사용자에게 보여질 수 있는 서비스의 이름. 이 애트리뷰트가 설정되지 않으면, 전체 애플리케이션에 대한 라벨 설정이 대신 사용된다(<application> 엘리먼트의 label 애트리뷰트를 보라).

서비스의 라벨은 ? 여기서 설정되던 또는 <application> 엘리먼트에서 설정되던 상관없이? 또한 모든 서비스의 인텐트 필터에 대한 디폴트 라벨이다 (<intent-filter> 엘리먼트의 label 애트리뷰트를 보라).

라벨은 사용자 인터페이스의 다른 문자열처럼 로컬라이즈될 수 있도록 문자열 리소스에 대한 레퍼런스로써 설정되어야 한다. 하지만 편의상 여러분이 애플리케이션을 개발하고 있는 동안 그것은 또한 원시 문자열로 설정될 수 있다.

android:name
The name of the Service subclass that implements the service. This should be a fully qualified class name (such as, "com.example.project.RoomService"). However, as a shorthand, if the first character of the name is a period (for example, ".RoomService"), it is appended to the package name specified in the <manifest> element.

There is no default. The name must be specified.

서비스를 구현하는 Service 서브클래스의 이름. 이것은 전체 클래스 이름이어야 한다(“com.example.project.RoomService”처럼). 하지만 단축형으로 이름의 첫 번째 캐릭터가 마침표인 경우(예를 들어 “.RoomService”), <manifest> 엘리먼트에 지정된 패키지 이름 끝에 붙여진다.

디폴트는 없다. 이름은 지정되어야만 한다.

android:permission
The name of a permission that that an entity must have in order to launch the service or bind to it. If a caller of startService(), bindService(), or stopService(), has not been granted this permission, the method will not work and the Intent object will not be delivered to the service.

If this attribute is not set, the permission set by the <application> element's permission attribute applies to the service. If neither attribute is set, the service is not protected by a permission.

For more information on permissions, see the Permissions section in the introduction and a separate document, Security and Permissions.

서비스를 런치하거나 그것에 바인드하기 위해 어떤 엔티티가 가져야 하는 퍼미션의 이름. 만약 startsService() , bindService() , 또는 stopService()의 호출자가 이 퍼미션을 부여받지 않는다면, 그 메쏘드는 작동하지 않을 것이며 인텐트 오브젝트는 서비스에 전달되지 않을 것이다.

만약 이 애트리뷰트가 설정되지 않으면, <application> 엘리먼트의 permission 애트리뷰트에 의해 설정된 퍼미션이 서비스에 적용된다. 만약 이 두개의 애트리뷰트가 설정되지 않는다면, 서비스는 퍼미션에 의해 보호되지 않는다.

퍼미션에 관한 더 많은 정보에 대해서, 앞에 나왔던 퍼미션 섹션과 8장. “보안과 퍼미션”을 보라.

android:process
The name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The <application> element's process attribute can set a different default for all components. But component can override the default with its own process attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the service runs in that process. If the process name begins with a lowercase character, the service will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

서비스가 실행되는 프로세스 이름. 보통, 애플리케이션의 모든 컴포넌트는 애플리케이션을 위해 생성된 디폴트 프로세스에서 실행된다. 그것은 애플리케이션 패키지와 같은 이름을 갖는다. <application> 엘리먼트의 process 애트리뷰트는 모든 컴포넌트에 대한 다른 디폴트를 설정할 수 있다. 하지만 컴포넌트는 그것 자신의 process 애트리뷰트를 사용해서 디폴트를 오버라이드 할 수 있으며, 이것은 다양한 프로세스에 걸쳐 여러분의 애플리케이션이 분포되는 것을 가능하게 한다.

만약 이 애트리뷰트에 할당된 이름이 콜론(“:”)으로 시작한다면, 애플리케이션에 사적private인 신규 프로세스가 필요할 때 생성되며, 서비스는 그 프로세스에서 실행된다. 만약 프로세스 이름이 소문자로 시작한다면, 서비스는 그 이름을 가지는 글로벌 프로세스에서 실행되며 이는 그렇게 하도록 하는 퍼미션을 가진 경우 가능하다. 이것은 다른 애플리케이션에 있는 컴포넌트가 하나의 프로세스를 공유하는 것을 가능하게 하며, 리소스 사용을 줄인다.

see also:
<application>
<activity>
introduced in:
API Level 1
↑ Go to top