I tried to use greenrobot pass data between activities and fragment,but I couldn't find a suitable tutorial that show how do it in detail. Based on what I have read so far I wrote some thing like this,but it doesn't work.how can I use green robot to pass data to an activity or fragment that has not been inialized yet?
MainActivity :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().post(new String("We are the champions"));
Intent intent = new Intent("com.test.Activity_Lessons");
startActivity(intent);
}
Activity_Lessons :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Some initializations
EventBus.getDefault().register(this);
//Other Stuff
}
public void onEventMainThread(String s){
Toast.makeText(getActivity(), s, Toast.LENGTH_LONG).show();
}
The event handler is never called here.what am I doing wrong?