Androidmanifest. xml)

Source: Internet
Author: User

Syntax (syntax ):

<Receiverandroid: enabled = ["true"
| "False"]
Android: exported = ["true"
| "False"]
Android: icon ="Drawable
Resource
"
Android: Label ="String
Resource
"
Android: Name ="String"
Android: Permission ="String"
Android: Process ="String">
...
</Cycler>

Included in (contained in ):

<Application>

Can contain ):

<Intent-filter>

<Meta-data>

Description ):

This element is used to declare a broadcast receiver (A broadcastreceiver subclass) as one of the application components. Broadcast receivers allow applications to receive broadcast intent objects sent by systems or other applications, even when other components of the application are not running, it can also receive broadcast messages from the system or other applications.

There are two ways to let the system know that the application user has a broadcast receiver:

1. In the application's inventory file, use this element to declare registration of a broadcast receiver;

2. dynamically create a broadcast receiver in the Code and register it using the context. registerreceiver () method. For more methods to dynamically create a receiver, see the boradcastreceiver class description.

 

Attributes (attributes ):

Android: Enabled

This attribute defines whether the system can instantiate the broadcast receiver. If it is set to true, it can be instantiated. If it is set to false, it cannot be instantiated. The default value is true.

<Application> the element has its own enabled attribute, which is applied to all components of the application, including the broadcast receiver. The attributes of the <Application> and <receiver> elements must be true to enable the broadcast receiver. If one of them is set to false, the broadcast receiver will not be instantiated.

Android: exported

This attribute indicates whether the broadcast receiver can receive messages from outside the application. If it is set to true, it can receive messages. If it is set to false, it cannot receive messages. If this parameter is set to false, the receiver can only receive messages sent by applications with the same application component or with the same user ID.

Its default value depends on the intent filter it contains. If the filter is not included, the receiver can only be called by an intent object with a specified class name, this means that the receiver can only be used inside the application (because the class name is usually unknown outside the application ). In this case, the default value is false. On the other hand, if the receiver contains at least one filter, it means that the receiver can receive intent objects from the system or other applications, so the default value is true.

This attribute is not the only method that limits the receipt of external calls by broadcast. It can also limit the external entities that can send messages to broadcast.

Android: icon

This attribute defines an icon that represents the broadcast receiver. This attribute must be set by a configurable resource that contains the image definition. If this attribute is not set, it is replaced by the icon attribute value of the <Application> element.

Whether this attribute or the icon attribute of the <Application> element, the icons they set are also the default icons of intent filters for all receivers.

Android: Label

This attribute sets a readable and understandable text tag for the broadcast receiver. If this attribute is not set, the label attribute value of the <Application> element is used instead.

Whether it is the label attribute of this attribute or the label attribute of the <Application> element, the labels they set are also the default labels of intent filters of all receivers.

You should use a string resource to set this attribute so that it can be localized just like other strings in the user interface. However, for the convenience of application development, native strings can also be used for setting.

Android: Name

This attribute value must be set using the Class Name of the broadcast receiver's implementation class. It is a subclass of the broadcastreceiver class. The full name of the class is usually used (for example, Com. example. Project. reportreceiver ). However, you can also use abbreviations (for example,. reportreceiver ). The system automatically adds the package name set by the package attribute in the <manifest> element to the abbreviated name.

Once an application is released, the name should not be changed (unless Android: exported = "false ").

This property has no default value and must be specified.

Android: Permission

This attribute defines the permissions required to send a message to the broadcaster of the broadcast receiver. If this attribute is not set, the permission set for the permission attribute of the <Application> element applies to this broadcast receiver. If no permission is set for the <Application> element, the receiver is not protected by the permission.

Android: Process

This attribute is used to set the name of the process in which the broadcast receiver should run. Generally, all components of an application are run in the default process created for the application. They have the same name as the application package name. <Application> the process attribute of an element can set a different default process for all its components, but its own process attribute of each component can override this default setting, in this way, an application can be separated into multiple processes.

If this property value starts with ":", the system will create a new private application process as needed, and the broadcast receiver will also run in this process. If the property value starts with a lower-case letter, the receiver runs the global process named after the property value, and it provides the permission to make it work. In this way, different application components are allowed to share the process.

Introduced version (introduced in ):

API Level 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.