I read that if we need to create fragment immediately, we have to call executePendingTransactions() method on FragmentManager. Well, that's what I'm trying to do. Like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.layout.fragmentContainer, new MyFragment);
fragmentTransaction.commit();
fragmentManager.executePendingTransactions();
foo(); // It is called before MyFragment's onCreateView()
}
I'd like to know why foo() method is called BEFORE MyFragment's onCreateView(). As you see, I'm calling executePendingTransactions() in UI Thread as it should be. I'm not messing here with threads at all.