Hi I have an activity which references a fragment.
public class MyActivity extends Activity{
private MyFragment myFragment;
.
.
.
private void navigateToFragment(){
if(myFragment==null){
myFragment = MyFragment.newInstance();
}
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.container, myFragment , tag);
transaction.addToBackStack(null);
transaction.commit();
}
Also my fragment has setRetainInstance set to true. The problem I'm having is that when the user navigates to MyFragment and then goes back to the activity, and then goes to MyFragment again, sometimes the layout is not loaded and none of the lifecycles events from MyFragment are called (onAttach, onResume, etc). What might be the cause of this?