I want to know
getFragmentManager()
.beginTransaction()
.replace(
R.id.main,
Fragment.instantiate(LoadingScreen.this,
"com.myapp.fragments.fragment1",
bundle)).commit();
and then later on we call
getFragmentManager()
.beginTransaction()
.replace(
R.id.main,
Fragment.instantiate(LoadingScreen.this,
"com.myapp.fragments.fragment2",
bundle)).commit();
What happens to the Fragment1 view ? Will it be destroyed automatically, do we have to manage any garbage collection on this ?
Kind Regards
According to the note on Android Developers:
When you remove or replace a fragment and add the transaction to the back stack, the fragment that is removed is stopped (not destroyed). If the user navigates back to restore the fragment, it restarts. If you do not add the transaction to the back stack, then the fragment is destroyed when removed or replaced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With