Why Android needs to broadcast broadcast

Source: Internet
Author: User

Why do you need a broadcast mechanism in Android? Broadcast mechanism, essentially it is a communication between the components, if the two components in different processes, then can be implemented with the binder mechanism, if the two components are in the same process, then they can be used to communicate between the way more, so that the broadcasting mechanism seems to be redundant. However, the broadcasting mechanism is irreplaceable, and it is not the same as the binder mechanism is that the sender and receiver of the broadcast does not need to know the other party's existence beforehand, so the benefit is that the system components can be loosely coupled together, so that the system is highly scalable, Easy integration with other systems.

In software engineering, high cohesion and low coupling between modules are very important, otherwise, as the system becomes larger, it will face the risk of becoming more and more difficult to maintain, resulting in the failure of the whole project. The organization of Android applications, it can be said that the high cohesion of the low coupling of the idea carried out very thoroughly, in any activity, can use a simple intent, through startactivity or StartService, You can start another activity or service to serve it, and it basically does not rely on the activity or service implementation, just need to know its name in string form, and the broadcast mechanism is more absolute, it even the recipient's name does not need to know.

But then again, the broadcasting mechanism in the Android system, is not what innovative things. If the reader understands Java EE or COM, it is known that in the Java EE, a message-driven bean (Message-driven bean) is provided to enable message passing between the various components of the application, whereas in COM, a connection point is provided (Connection Point), which is also used to deliver messages between the various groups of applications. Whether it is the message-driven bean in the Java EE, the connection point in COM, or the broadcast mechanism of the Android system, the implementation mechanism is the event-driven model of the message publish/subscribe pattern, the message producer publishes the event, and the consumer subscribes to the event of interest.

Excerpt from: http://blog.csdn.net/luoshengyang/article/details/6730748

Why Android needs to broadcast broadcast

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.