I have this odd problem that my fragments are not calling any of the end lifecycle methods like onPause and onStop when I replace it with another fragment. I replace the fragment like this
public static void replaceFragment(Activity activity, int layoutId, Fragment fragment, String title, String shortTitle) {
FragmentTransaction transaction = activity.getFragmentManager().beginTransaction().replace(layoutId, fragment);
transaction.addToBackStack(title);
transaction.setBreadCrumbTitle(title);
transaction.setBreadCrumbShortTitle(shortTitle);
transaction.commit();
activity.getFragmentManager().executePendingTransactions();
}
I think it is somehow keeping my fragment alive even if i popBackStack cause after replacing the same fragment again after it have been shown ones before then it also calls the onStop before onStart?
Activity
orFragment
classes) and forgotten to delegate the call to thesuper
? There is nothing wrong with the code snippet in your question, so the problem is probably somewhere in the hostingActivity
or one of yourFragment
classes. Without any more details I'm afraid is going to be impossible to further pinpoint the exact issue. – Ferroconcrete