java.lang.IllegalStateException: Failure saving state: active has cleared index in fragment

前端 未结 3 1208
别跟我提以往
别跟我提以往 2021-02-13 04:51

First, my app has structure like this:

 SpashActivity -> MainActivity -> switching between many fragments

My app use SlideMenu to switch

3条回答
  •  误落风尘
    2021-02-13 05:27

    Possible problem with reading fragment stat between detach and attach.

    Try to use something like this:

    FragmentTransaction ft = fragmentManager.beginTransaction();
    
    //ft.detach(fragment).attach(fragment).commitAllowingStateLoss(); // crashing
    
    ft.replace(getView().getId(), fragment).commitAllowingStateLoss(); // not crashing
    

提交回复
热议问题