The recommended modern way for two fragments to share data is:

  1. A shared ViewModel scoped to the activity
  2. Restarting the activity
  3. Writing to a text file
  4. 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