How can I receive a value from a Fragment even before that has been started in Android [Kotlin]

Viewed 26

I have a scenario where I have let's say three fragments A,B,C. Now I simply want to move from fragment A to B. But to move from A to B I have to enter a code in the EditText of Fragment A and press the button, but this code is coming from Fragment C.

Or in a more detailed situation the Fragment C belongs to an another activity. So activity 1 with two Fragments A and B while activity 2 have one fragment C.

When the activity 2 is started and so is the attached fragment's onViewCreated is called, I will generate a code but I need that code in activity 1 (where activity 2 has not even being initialized! so how can I get that code?)

What is an ideal way to deal with such situations? Any help would be appreciated.

P.S - This is a brief of a complex scenario I am working with.

0 Answers
Related