None of the answers above worked for me, the reason for this problem was quite simple, because I used some of them FragmentStatePagerAdapter, and the saveState method saves the state of the fragments, because one of my fragments was quite large, so saving this fragment leads to this TransactionTooLargeExecption .
I tried to override the saveState method in my pager implementation as indicated by @ IK828, but this could not solve the problem.
In my fragment there was an EditText, which was used to store very large text, which was the culprit of the problem in my case, so just in the onPause () of the fragment I set the edittext text to an empty line. i.e:
@Override public void onPause() { edittext.setText(""); }
Now that the FragmentStatePagerAdapter tries to save state, this large piece of text will not be there to consume most of it, therefore, it resolves the failure.
In your case, you need to find what is the culprit, it can be an ImageView with some bitmap, a TextView with a huge chunk of text, or any other high memory consumption, you need to free up memory, you can set the image to .setImageResource (null) or similar in onPause () of your fragment.
update: onSaveInstanceState is better for this purpose before calling super:
@Override public void onSaveInstanceState(Bundle outState) { edittext.setText(""); super.onSaveInstanceState(outState); }
or as @Vladimir pointed out, you can use android: saveEnabled = "false" or view.setSaveEnabled (false); in the view or user view and make sure it is set to onResume, otherwise it will be empty when the action resumes.
Ankush Chugh Nov 20 '17 at 18:45 2017-11-20 18:45
source share