I am replacing a Fragment with another one:
FragmentTransaction transaction = mFragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
transaction.replace(R.id.main_container, nextFragment, nextFragment.getClass().toString());
transaction.addToBackStack(nextFragment.getClass().toString());
transaction.commit();
however, the fragment thats being replaced, its onSaveInstanceState is not called. what am i doing wrong?
"In a Fragment, all of their lifecycle callbacks are directly tied to their parent Activity. So onSaveInstanceState gets called on the Fragment when its parent Activity has onSaveInstanceState called."
Look at this post:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.