依赖
implementation 'org.greenrobot:eventbus:3.0.0'
EventBus 注册
public class MoEvent implements Serializable {
public String string;
public MoEvent(String string) {
this.string = string;
}
}
传值
EventBus.getDefault().post(new MoEvent("啥东东"));
接收 粘性
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void onLogin(MoEvent moEvent){
String string = moEvent.string;
}