getting exception “IllegalStateException: Can not perform this action after onSaveInstanceState”

前端 未结 30 2097
迷失自我
迷失自我 2020-11-22 05:12

I have a Live Android application, and from market i have received following stack trace and i have no idea why its happening as its not happening in application code but it

30条回答
  •  遇见更好的自我
    2020-11-22 05:47

    I think Lifecycle state can help to prevent such crash starting from Android support lib v26.1.0 you can have the following check:

    if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)){
      // Do fragment's transaction commit
    }
    

    or you can try:

    Fragment.isStateSaved()
    

    more information here https://developer.android.com/reference/android/support/v4/app/Fragment.html#isStateSaved()

提交回复
热议问题