I\'m sending an interface from Fragment 5 to 3 through the main activity :
public void setF3Riddle(int x) {
Frag3 F3 = (Frag3) getSupportFragmentManager().fin
The problem probably is from here:
Frag3 frag = new Frag3();
Bundle args = new Bundle();
args.putInt("Value", x);
frag.setArguments(args);
getSupportFragmentManager().beginTransaction()
.replace(R.id.Frag3, frag)
.addToBackStack(null)
.commit();
frag.getF3Riddle(x);
You're creating the fragment with Frag3 frag = new Frag3();
and put the bundle then you want to get the value with frag.getF3Riddle(x)
. But it will throw an error because the the fragment is not yet finished created. Fragment creation is asynchronous process. So, you need to wait until the frag is finished created or create it in another place first.