Android uses Eventbus for data transfer

Source: Internet
Author: User
Tags eventbus

In the project, the inevitable to two pages between the data transfer, even if not delivery, but also need to be refreshed and so on, we are based on the Library class method provided by Google, but also can do, mainly broadcast broadcastreceiver, StartActivity methods or application instances and so on, are all working (as long as the implementation is good, after all, the function implementation takes precedence over the code structure?). )。

But at the same time there is a problem, that is the high degree of coupling of the code, such as broadcasting, you have to write an internal class, inherit from the system's broadcast class, and then also need to enter the page before the new and register the broadcast, and then do not use, but also need a one-off, or there is a risk of memory leaks

Then send a broadcast where you need to notify this page of an update or other action. The action of this broadcast must also be the same as the registered action. Imagine, if you change the registered action, you also have to find the corresponding code to send the broadcast, at the time of modification. There is a certain limit to this coupling.

But another decoupled third-party component we're using here can help us solve the problem. Please see the links below for more details on how to use the entry level, easy to understand.

1, http://blog.csdn.net/harvic880925/article/details/40660137

2, http://blog.csdn.net/harvic880925/article/details/40787203


Thank bloggers for sharing!

Android uses Eventbus for data transfer

Related Article

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.