Could not dispatch event
04-18 14:10:11.062 4790-4790/com. E/EventBus: Could not dispatch event: class com..LoginEvent to subscribing class class .**.FragmentMy
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842)
switch Fragment
public void switchFrag(Fragment from, Fragment to){ if (this.frag != to){ this.frag = to; FragmentTransaction ft = fm.beginTransaction(); if(!to.isAdded()){ ft.hide(from).add(R.id.frag_container,to).commit(); }else { ft.hide(from).show(to).commit; } } }
commit() —> commitAllowingStateLoss()
public void switchFrag(Fragment from, Fragment to){
if (this.frag != to){
this.frag = to;
FragmentTransaction ft = fm.beginTransaction();
if(!to.isAdded()){
ft.hide(from).add(R.id.frag_container,to).commitAllowingStateLoss();
}else {
ft.hide(from).show(to).commitAllowingStateLoss();
}
}
}