Home > Blockchain >  How to get callback in fragment when it's in stack (currently not visible)
How to get callback in fragment when it's in stack (currently not visible)

Time:08-04

I want callback in fragment when it's not currently visible

Ex: I am opening FragmentA then I am opening FragmentB now I am updating list sequence in FragmentB after updating list sequence I also want to update list in FragmentA before opening it (want to update list in FragmentA when FragmentB is visible)

I have not perform .popBackStack() in FragmentB

Now if I update list seqeuence 2nd time then list sequence in FragmentA should update

In sort : I want callback in fragment when it's not currently visible

Is it posible?

CodePudding user response:

your best option is using the shared view model in which your both fragment will use on view Model and you don't need to worry about the lifecycle of your fragments. take a look at the link below

sharedviewModel

CodePudding user response:

You have several options to achieve this, it depends on many factors such as the context of your task, what type of data you want to share between fragments, what type of architecture in your project, and whether the data should be persistent in the memory or, database or another cache, etc.

  • Related