<receiver>

syntax:
<receiver 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" >
    . . .
</receiver>
contained in:
<application>
can contain:
<intent-filer>
<meta-data>
description:
Declares a broadcast receiver (a BroadcastReceiver subclass) as one of the application's components. Broadcast receivers enable applications to receive intents that are broadcast by the system or by other applications, even when other components of the application are not running.

There are two ways to make a broadcast receiver known to the system: One is declare it in the manifest file with this element. The other is to create the receiver dynamically in code and register it with the Context.registerReceiver() method. See the BroadcastReceiver class description for more on dynamically created receivers.

애플리케이션 컴포넌트 중 하나인 브로드캐스트 리시버(BroadcastReceiver 서브클래스)를 선언한다. 브로드캐스트 리시버는 애플리케이션의 다른 컴포넌트들이 실행되지 않을 때 조차도 다른 애플리케이션 또는 시스템에 의해 브로드캐스트되는 인텐트를 받기 위해 애플리케이션을 활성화한다.

시스템에게 브로드캐스트 리시버를 알리기 위한 두 가지 방법이 있다: 하나는 이 엘리먼트를 가지고 매니페스트 파일 안에 그것을 선언하는 것이다. 다른 하나는 코드 안에서 동적으로 리시버를 만들어서 Context.registerReceiver() 메쏘드를 사용해서 그것을 등록하는 것이다. 동적으로 만들어진 리시버에 대한 더 많은 것은 BroadcastReceiver 클래스 설명을 보라.

attributes:
android:enabled
Whether or not the broadcast receiver 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 broadcast receivers. The <application> and <receiver> attributes must both be "true" for the broadcast receiver to be enabled. If either is "false", it is disabled; it cannot be instantiated.

브로드캐스트 리시버가 시스템에 의해 인스턴스화 될 수 있는 지 여부 ? 만약 될 수 있다면 “참true” 아니라면 “거짓false”이다. 디폴트 값은 “참true”이다.

<application> 엘리먼트는 브로드캐스트 리시버를 포함하는 모든 애플리케이션 컴포넌트들에게 적용되는 그것 자신의 enabled 애트리뷰트를 갖는다. 브로드캐스트 리시버가 활성화될 수 있게 하기 위해서는 <application>과 <receiver> 애트리뷰트 모두가 “참true”이 되어야 한다. 만약 어느 것 하나가 “거짓false”이라면, 그것은 비활성화된다; 그것은 인스턴스화될 수 없다.

android:exported
Whether or not the broadcast receiver can receive messages from sources outside its application "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID.

The default value depends on whether the broadcast receiver contains intent filters. The absence of any filters means that it can be invoked only by Intent objects that specify its exact class name. This implies that the receiver is intended only for application-internal use (since others would not normally 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 broadcast receiver is intended to receive intents broadcast by the system or other applications, so the default value is "true".

This attribute is not the only way to limit a broadcast receiver's external exposure. You can also use a permission to limit the external entities that can send it messages (see the permission attribute).

브로드캐스트 리시버가 그것의 애플리케이션 외부의 소스로부터 메시지를 받을 수 있는지 여부 ? 만약 할 수 있으면 “참true” 아니라면 “거짓false”이다. 만약 “거짓false”이라면 브로드캐스트 리시버가 받을 수 있는 유일한 메시지는 동일 애플리케이션의 또는 동일 유저user ID를 가지는 애플리케이션의 컴포넌트에 의해 보내진 것들이다.

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

이 애트리뷰트가 브로드캐스트 리시버의 외부 노출을 제한하는 유일한 방법은 아니다. 여러분은 또한 그 브로드캐스트리시버에 메시지를 보낼 수 있는 외부 엔티티를 제한하는 퍼미션을 사용할 수 있다(permission 애트리뷰트를 보라).

android:icon
An icon representing the broadcast receiver. 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 broadcast receiver's icon whether set here or by the <application> element is also the default icon for all the receiver's intent filters (see the <intent-filter> element's icon attribute).

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

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

android:label
A user-readable label for the broadcast receiver. 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 broadcast receiver's label whether set here or by the <application> element is also the default label for all the receiver'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 class that implements the broadcast receiver, a subclass of BroadcastReceiver. This should be a fully qualified class name (such as, "com.example.project.ReportReceiver"). However, as a shorthand, if the first character of the name is a period (for example, ". ReportReceiver"), it is appended to the package name specified in the <manifest> element.

There is no default. The name must be specified.

브로드캐스트 리시버, 즉 BroadcastReceiver의 서브클래스를 구현하는 클래스의 이름. 이것은 정확한 전체 클래스 이름이어야 한다(“com.example.project.ReportReceiver” 와 같이). 하지만 단축형으로 이름의 첫 번째 문자가 마침표라면(예를 들어 “. ReportReceiver”), 그것은 <manifest> 엘리먼트에 지정된 패키지 이름 끝에 붙여진다.

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

android:permission
The name of a permission that broadcasters must have to send a message to the broadcast receiver. If this attribute is not set, the permission set by the <application> element's permission attribute applies to the broadcast receiver. If neither attribute is set, the receiver 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.

브로드캐스터가 브로드캐스트 리시버에게 메시지를 보내기 위해 가져야 하는 퍼미션의 이름. 만약 이 애트리뷰트가 설정되지 않으면, <application> 엘리먼트의 permission 애트리뷰트에 의해 설정된 퍼미션이 브로드캐스트 리시버에 적용된다. 만약 둘 모두의 애트리뷰트가 설정되지 않으면, 그 리시버는 퍼미션에 의해 보호되지 않는다.

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

android:process
The name of the process in which the broadcast receiver should 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 each 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 broadcast receiver runs in that process. If the process name begins with a lowercase character, the receiver 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인 신규 프로세스가 필요할 때 생성되며, 브로드캐스트 리시버는 그 프로세스에서 실행된다. 만약 프로세스 이름이 소문자로 시작된다면, 리시버는 그 이름을 가지는 글로벌 프로세스에서 실행되며, 이것은 그렇게 하도록 하는 퍼미션을 가지는 경우에 가능하다. 이것은 다른 애플리케이션의 컴포넌트들이 하나의 프로세스를 공유하게 하며, 리소스 사용을 감소시킨다.

introduced in:
API Level 1
↑ Go to top