It seems that when a fragment A is replaced by a fragment B, A.onResume() is called before stopping fragment A.
I'm performing initializations in A.onResume() and I would like to avoid calling them when A is removed.
Is it possible to:
- avoid calling A.onResume() when replacing this fragment ?
- detect in A.onResume() that this call is generated because the fragment is being replaced ?
here is my code for replacing the fragment:
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.main_content, fragment);
ft.commit();