3

There are several different kinds of fragmentManagers in Android: parentFragmentManager, childFragmentManager, supportFragmentManager and plain fragmentManager, which is already deprecated. But what are the principal differences between them?

Ksenia
  • 3,453
  • 7
  • 31
  • 63

1 Answers1

0

FragmentManager is responsible for all runtime management of fragments including adding, removing, hiding, showing, or otherwise navigating between fragments. Plain fragmentManager was used for fragments that come from pure android (and behaviour of this fragments can be changed by vendors). So guys from Google introduced Support Library and started providing many android components as dependencies.

And supportFragmentManager comes into play. It completely replaces old fragmentManager. And if you use fragments from Support Library, then you should use supportFragmentManager for work with fragments.

ChildFragmentManager:

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

So this manager is used for nested navigation inside fragment. For example you have some kind of HomeFragment which has container and you want to show nested fragments inside that fragment.

More info: SOF, FragmentManager, ChildFragmentManager

Ruslan Myhal
  • 266
  • 1
  • 2
  • 9