I am working on an Android project → Target SDK Version - 25 Build Tools Version 25.0.2
Currently, I started getting StateLoss Crash. Search on Google, found many answers on Stackoverflow.
First of all, I can not imitate this problem. Just view this issue in Crashlytics as
Fatal Exception: java.lang.IllegalStateException
Can not perform this action after onSaveInstanceState
There is not enough information in the stack trace to understand. After some searching, I think the problem is with committing fragments. My example commit code is shown below. Please note that all commits are made internally.onPostResume()
Fragment f = getSupportFragmentManager().findFragmentByTag("LandingFragment");
android.support.v4.app.FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
if(f == null && !isFinishing() && !isDestroyed()){
f = new LandingFragment();
tr.replace(R.id.onboarding_view_fragment_container, f, "LandingFragment");
tr.commit();
}
, commitAllowingStateLoss(), , . , http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html
. , , ... , ?
,
android.support.v4.app.FragmentManagerImpl.checkStateLoss (SourceFile:1538)
android.support.v4.app.FragmentManagerImpl.enqueueAction (SourceFile:1556)
android.support.v4.app.BackStackRecord.commitInternal (SourceFile:696)
android.support.v4.app.BackStackRecord.commit (SourceFile:662)
android.support.v4.app.FragmentTabHost.onAttachedToWindow (SourceFile:288)
android.view.View.dispatchAttachedToWindow (View.java:13799)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:2860)