Consider the situation:
There is mainActivity. Form this activity we can call two fragments: fragmentA and fragmentB.
mainActivity has one getter getValue and one setter setValue.
Most of the time this is how application works: mainActivity is created. From it fragmentA is created. After back button is pressed in fragmentA, application moves back to mainActivity and goes to fragmentB.
What I want to do is, I want to setValue to mainActivity in fragmentA and get that value in fragmentB.
I am not able to do this since it looks like both fragments do not have the same instance of activity.
This is how I try to access setters/getters of mainActivity from fragmentA and fragmentB: ((MainActivity)getContext()).getValue();
What am I doing wrong?