The recommended modern way for two fragments to share data is:
- A shared ViewModel scoped to the activity
- Restarting the activity
- Writing to a text file
- Calling each other's methods directly
Answer
A) A shared ViewModel scoped to the activity
activityViewModels() gives both fragments the same ViewModel.
Computer Science MCQ · More Windows Mobile, Eclipse and Fragments MCQs · Practise