activity1 :触发事件:
public void manager(View view) {
Intent intent = new Intent(this, EditDialogActivity.class);
intent.putExtra(EditDialogActivity.Extra_Edit_Title, getString(R.string.manager_server));
startActivity(intent);
}
另外的接受activity2:
String title=null;
title = getIntent().getStringExtra(Extra_Edit_Title);
EventBus传输时间:
无需注册接受端:
发射处:
Eventbus eventbus;
eventBus = org.greenrobot.eventbus.EventBus.getDefault();
还有个unregister的地方
ScreenRenderApp.APP.getEventBus().register(this);
eventbus.post(new xxxEvent());
需要定义一个eventbus事件结构体类,例如:
public class CPicDownloadEvent {
Bitmap bitmap;
String path;
public CPicDownloadEvent(Bitmap bitmap,String path) {
this.bitmap=bitmap;
this.path=path;
}
public Bitmap getBitmap() {
return bitmap;
}
public String getPath() {
return path;
}
}
然后在写个接受的地方:注意此地方必须是或者存在的,如果activity已destroy就无法接收到。
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEthernetChange(EthernetChangeEvent event) {
checkNetworkConnection();
}
:接收端也需要注册才能收到 ScreenRenderApp.APP.getEventBus().register(this);