Senior Software Engineer @ Acorns
// This is the initial
// fragment the user sees
fragmentManager.commit {
setReorderingAllowed(true)
replace<HomeFragment>(R.id.container)
}
// add transactions to the back stack
fragmentManager.commit {
setReorderingAllowed(true)
replace<ProfileFragment>(R.id.container)
addToBackStack(“profile”)
}
fragmentManager.commit {
setReorderingAllowed(true)
replace<EditProfileFragment>(R.id.container)
addToBackStack(“edit_profile”)
}
// save current back stack
fragmentManager.saveBackStack("profile")
// add new fragament transaction
fragmentManager.commit {
setReorderingAllowed(true)
replace<NotificationsFragment>(R.id.container)
addToBackStack("notifications")
}
// save current back stack
fragmentManager.saveBackStack(“notifications”)
// restore prior back stack
fragmentManager.restoreBackStack(“profile”)