I have a ViewPager2
in one of my fragments (let's call it fragment A). the viewpager uses a FragmentStateAdapter
to create a number of fragments as the children (let's call these fragments children
). when the user clicks on a button in fragment A, I replace it with fragment B.
now when the user clicks on device back button to come back to fragment A, I can see that children are automatically restored by the system (they are not shown in viewpager, but the onCreateView method of them are called and the saved bundle is delivered to them). how to avoid this behavior. I do not want children to be automatically recreated and restored.