Good day, I have three activities with their corresponding fragments A, B and C. Fragment A is a static fragment the others fragments are dynamic.
Activity A is already implementing a listener for fragment A, which is used to load fragment B in landscape orientation or move to new screen in single pane.
What i want is when a certain button is pressed in fragment B which calls up fragment C, I want it to be replaced by fragment C in landscape orientation(fragment A will still be present) or bring up a new screen in single pane mode. I have this simple code in the activity B onCreate method:
if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
finish();
return;
}
I am trying to avoid fragment to fragment communication since it is frowned at. So does this mean I have to implement listeners for fragment B in both activity A and B, am guessing that when in landscape orientation activity A would load up fragment C and in portrait, B takes over? Is there a better way?. I thought of only implementing the listener in activity B and passing to activity A when in landscape orientation but I think it would have been finished before it even got to pass due to the above code. Any thoughts?