implementation 'org.greenrobot:eventbus:3.1.1'
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
setContentView(R.layout.page1);
EventBus.getDefault().post("123");
}
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void doEventBus(MessageBean messageBean){
if(messageBean.equals('123')){
Log.d(TAG, "1");
}
if(messageBean.equals('123')){
Log.d(TAG, "2");
}
if(messageBean.equals('123')){
Log.d(TAG, "3");
}
Log.d(TAG, "4");
}
EventBus eventBus=EventBus.builder().eventInheritance(false).build();
EventBus.getDefault().postStickyEvent(event);
EventBus.getDefault().removeStickyEvent(event);