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