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