Why does the lab check if (savedInstanceState == null) before showing HomeFragment?

  1. To clear the back stack
  2. To save battery
  3. To request permissions
  4. To avoid adding a duplicate fragment after rotation, since the FragmentManager restores fragments
Answer

D) To avoid adding a duplicate fragment after rotation, since the FragmentManager restores fragments

After recreation the existing fragment is restored automatically.

Computer Science MCQ · More Lab: Bottom Navigation with Fragments MCQs · Practise