0

I have a Fragment hosted in an Activity.

In the Activity i have a list of categorized items. By clicking a button, a Fragment opens and there i have a list of all categories.

The user can select an item, than by clicking a button inside the Fragment, this once must pass the result to his hosting Activity and close itself.

The main problem is that i have to create a "modular" way to do this, so i can't use something like mActivity.category = "123" or call a method inside the Activity like mActivity.setCategory("123").

Is there a way to pass the result data like the system onActivityResult / startActivityForResult does, applyed to Activity -> Fragment?

MikeKeepsOnShine
  • 1,730
  • 4
  • 23
  • 35

1 Answers1

0

Yes of course, check this callback example. You could also use Intents, but callbacks should be ok for you.

dalyan
  • 61
  • 2