Facebook Interview Question
Android EngineersCountry: India
Interview Type: Phone Interview
I think there would be few differences
- Life cycle awareness in Fragments.
- Handling state of Fragment on Back Navigation, that is already covered by previous answer.
- Views can not be be fully incapsulated in many cases. It means Views can not be used as fully adaptable. For example if something you need to do with starting an Intent and listening the result (startActivityForResult() and onActivityResult()), you need to be relay on Activity and you may be repeating same code again and again.
- Navigations are not for View.
- Views are lightweight, and when lifecycle not required we do not need to use Fragment. For example, a circular view. If I want to show such view, I would go for View not Fragment.
One more important difference is Stack. It's really hard to preserve the view state when the user clicks the back button. Whereas in fragments, the fragment manager can able to manage the fragment's state using stack
- Boobalan Munusamy May 07, 2020