public interface

FragmentManager.OnBackStackChangedListener

 androidx.fragment.app.FragmentManager.OnBackStackChangedListener

Overview

Interface to watch for changes to the back stack.

Summary

Methods
public voidonBackStackChangeCancelled()

Called whenever a predictive back gesture is cancelled.

public voidonBackStackChangeCommitted(Fragment fragment, boolean pop)

Called whenever the contents of a back stack change is committed.

public voidonBackStackChanged()

Called whenever the contents of the back stack change, after the fragment manager has moved all of the fragments to their final state.

public voidonBackStackChangeProgressed(BackEventCompat backEventCompat)

Called whenever a predictive back gesture is changing the back stack.

public voidonBackStackChangeStarted(Fragment fragment, boolean pop)

Called whenever the contents of the back stack are starting to be changed, before any fragment actually changes its lifecycle state.

Methods

public void onBackStackChanged()

Called whenever the contents of the back stack change, after the fragment manager has moved all of the fragments to their final state.

This is the final callback that will be delivered to the listener in all cases except for when the predictive back gesture is cancelled. It will be called after FragmentManager.OnBackStackChangedListener.onBackStackChangeCommitted(Fragment, boolean).

public void onBackStackChangeStarted(Fragment fragment, boolean pop)

Called whenever the contents of the back stack are starting to be changed, before any fragment actually changes its lifecycle state. If this is caused by a forward transaction and the given fragment is incoming, it will return false from Fragment.isRemoving(). If this is caused by a pop operation and the given fragment is being popped, it will return true from Fragment.isRemoving().

This is the first callback that will be delivered to the listener. If the transaction is caused by a predictive back gesture, it will be followed by an FragmentManager.OnBackStackChangedListener.onBackStackChangeProgressed(BackEventCompat) callback otherwise, the next callback will be FragmentManager.OnBackStackChangedListener.onBackStackChangeCommitted(Fragment, boolean).

Parameters:

fragment: one of the fragments that is affected by the starting back stack change
pop: true, if this callback was triggered by a pop operation, false otherwise

public void onBackStackChangeProgressed(BackEventCompat backEventCompat)

Called whenever a predictive back gesture is changing the back stack. This will continue to be called with an updated object until the gesture is either cancelled or completed.

This is called immediately after FragmentManager.OnBackStackChangedListener.onBackStackChangeStarted(Fragment, boolean) during a predictive back gesture. If the gesture is completed, this will be followed by FragmentManager.OnBackStackChangedListener.onBackStackChangeCommitted(Fragment, boolean) and if it is cancelled, it will be followed by FragmentManager.OnBackStackChangedListener.onBackStackChangeCancelled().

Parameters:

backEventCompat: provides the current progress of the active predictive back gesture

public void onBackStackChangeCommitted(Fragment fragment, boolean pop)

Called whenever the contents of a back stack change is committed. If this is caused by a forward transaction and the given fragment is incoming, it will return false from Fragment.isRemoving(). If this is caused by a pop operation and the given fragment is being popped, it will return true from Fragment.isRemoving().

This is called immediately after FragmentManager.OnBackStackChangedListener.onBackStackChangeStarted(Fragment, boolean) for a forward transaction or for a non-predictive back pop. If this is caused by a predictive back gesture, it will be called after FragmentManager.OnBackStackChangedListener.onBackStackChangeProgressed(BackEventCompat) before the fragment moves to the final state.

Parameters:

fragment: one of the fragments that is affected by the committed back stack change
pop: true, if this callback was triggered by a pop operation, false otherwise

public void onBackStackChangeCancelled()

Called whenever a predictive back gesture is cancelled.

This is called immediately after FragmentManager.OnBackStackChangedListener.onBackStackChangeProgressed(BackEventCompat) once a predictive back gesture has been cancelled and will place the FragmentManager back into the state before the predictive back gesture was started.