When u sends data from fragment A to fragment B, use the same logical values as below: -
FragmentA → FragmentB
FragmentB ldf = new FragmentB ();
Bundle args = new Bundle();
args.putBoolean("BOOLEAN_VALUE",true);
ldf.setArguments(args);
getFragmentManager().beginTransaction().add(R.id.container, ldf).commit();
And when u sends data from fragment C to fragment B, use the same BOOLEAN that is used in fragment AB, as shown below -
FragmentC → FragmentB
FragmentB ldf = new FragmentB ();
Bundle args = new Bundle();
args.putBoolean("BOOLEAN_VALUE",false);
ldf.setArguments(args);
getFragmentManager().beginTransaction().add(R.id.container, ldf).commit();
And in the latter case, we must check that the value is received in FragmentB, where, for example, a fragment A OR FragemntC
Fragmentb
Boolean getValue= getArguments().getBoolean("BOOLEAN_VALUE");
if(getValue)
{
}
else
{
}
source
share