EventBus

依赖:

compile 'org.greenrobot:eventbus:3.0.0'

注册,通常放在onCreate中:

EventBus.getDefault().register(this);

解除注册,通常放在onDestroy中:

if(EventBus.getDefault().isRegistered(this)) {
    EventBus.getDefault().unregister(this);
}

注册后,可以发送消息:

EventBus.getDefault().post("hello");

在接收的布局中进行操作:

@Subscribe(threadMode = ThreadMode.MAIN) 
public void Event(String)
{

}
原文地址:https://www.cnblogs.com/zhaozilongcjiajia/p/10511980.html