Description
Fragments are destroyed and recreated with their parent Activity. The setRetainInstance in a fragment, allows us to skip this cycle. The fragment is then retained. This is used to avoid memory leaks.
Example
Due to time issues, I did not create an example for retaining fragments, but here is a good example.
If the fragment already started before, then it does not have to be created.
Check this page to view the complete repository.