Android 使用EventBus发送消息接收消息

基本使用

自定义一个类

public class LoginEvent {
private String code;//是否成功

public LoginEvent(String code) {
this.code = code;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}
}

在要接收消息的页面注册:

   eventBus.register(this);  

public void onEventMainThread(LoginEvent event) {

}

 

解除注册

eventBus.unregister(this);  



引入EventBus:
compile 'org.greenrobot:eventbus:3.0.0'



posted on 2016-10-13 17:53  赵磊磊  阅读(2920)  评论(0编辑  收藏  举报

导航