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'




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM