Question, How can an AppCompatActivity communicate with FragmentActivity using the EventBus?
Findings, FragmentActivity can communicate with AppCompatActivity and the onEvent method is called, but if we switch the communication path to AppCompatActivity communicates with FragmentActivity, the onEvent method is never called.
public class MainActivity extends AppCompatActivity{
private String data;
@Override protected void onCreate{
data = "private String data from MainActivity";
EventBus.getDefault().postSticky(data);
}
}
public class AccountFade extends FragmentActivity{
private String mAccountFadeData;
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEvent(String s){
Toast.makeText(this, "private String mAccountFadeData from MainActivity", Toast.LENGTH_LONG).show();
this.mAccountFadeData = s;
}
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
}
@Override public void onDestroy(){
EventBus.getDefault().unregister(this);
super.onDestroy();
}
}