EventBus: Could not dispatch event: class com.********.LoginEvent to subscribing class

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();
            }
        }
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章