EventBus
implementation 'org.greenrobot:eventbus:3.2.0'
EventBus
package com.qiqi.app.bean; public class EventMessageWrap { public final String message; public static EventMessageWrap getInstance(String message) { return new EventMessageWrap(message); } private EventMessageWrap(String message) { this.message = message; } }
发送fragment:
EventBus.getDefault().post(EventMessageWrap.getInstance("1"));
接收fragment:
EventBus.getDefault().register(this);
EventBus.getDefault().unregister(this);
@Subscribe(threadMode = ThreadMode.MAIN) public void onGetMessage(EventMessageWrap message) { getBannerData(); getTemplateClassification(); }