Why does the lab check if (savedInstanceState == null) before showing HomeFragment?
- To clear the back stack
- To save battery
- To request permissions
- 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