My app has several fragments and activities. Over the course of the main parent activity\'s lifecycle, the app presents information/options to the user in other activities.
You can commit fragment transactions again when your parent activity is resumed/started, even if it has been previous paused. The docs only mean that you cannot commit during the period of time where the activity is paused (and the state has been saved) and before it has been resumed again. If you return to your parent activity after visiting another activity, you are free to use fragment transactions again after Activity.onStart()
has been called.
The reason for this restriction is that Android saves the state of fragments associated with an Activity during Activity.onSaveInstanceState()
. If you try to make fragment transactions after this point, then you will be exposed to state loss if Android needs to recreate + restore that Activity (since the information it uses to recreate the Activity state was only the data that was captured in Activity.onSaveInstanceState()
).