Android ViewPager IllegalStateException: Can not perform this action after onSaveInstanceState

StackOverflow https://stackoverflow.com/questions/7328392

سؤال

I am using a ViewPager from the compatibility library. I get this exception quite often from the market reports.

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1242)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1253)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:535)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:519)

Any ideas what might cause it?

هل كانت مفيدة؟

المحلول

You are probably calling FragmentTransaction.commit() in the wrong place. It needs to be called before state is saved.

نصائح أخرى

Try commitAllowingStateLoss() instead of commit(). Read the documentation here.

Got answer from here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top