Archie
07/29/2020, 6:03 AMFragmentTransaction
ourselves, we have situation where we need to jump to a certain destination fragment but also have to create the backstack along the way. For example:
A -> B -> C -> D
so in code we do:
fun jumpToDFromA() {
// Assuming in in A
fragmentManger.beginTransaction()
.replace(id, B())
.addToBackStack("state1")
.setReorderingAllowed(true)
.commit()
fragmentManger.beginTransaction()
.replace(id, C())
.addToBackStack("state2")
.setReorderingAllowed(true)
.commit()
fragmentManger.beginTransaction()
.replace(id, D())
.addToBackStack("state3")
.setReorderingAllowed(true)
.commit()
}
With this, I am able to Jump to D
but also have the backstack A -> B -> C
.
Is this possible to do in Navigation Component
?allan.conda
07/29/2020, 7:55 AMallan.conda
07/29/2020, 7:56 AMval pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.nav_graph)
.setDestination(R.id.android)
.setArguments(args)
.createPendingIntent()
populates the backstack based on the graphArchie
07/29/2020, 7:58 AMallan.conda
07/29/2020, 8:02 AMDeep linking simulates manual navigationalthough if you meant a kind of navigation backstack that is not possible with manual navigation, I’m not sure 😅
Archie
07/29/2020, 8:03 AMokarm
07/29/2020, 8:32 AMIan Lake
07/29/2020, 1:55 PMnavigate
multiple times in a rowIan Lake
07/29/2020, 1:56 PMArchie
07/29/2020, 1:58 PMnavigate()
consecutively? is there any other check that needs to be done? As doing navigate(actionId)
where the actionId
isnt defined in the current destination
causes an error.Archie
07/29/2020, 1:59 PMdeeplink
ing only the startDestination
gets added in the backstack?Ian Lake
07/29/2020, 2:06 PMnavigate
updates the state synchronously, so as long as the destination you're going to supports the next navigate
call, then you're good to goIan Lake
07/29/2020, 2:08 PMIan Lake
07/29/2020, 2:10 PMArchie
07/29/2020, 2:14 PMd4vidi
07/29/2020, 6:13 PMusers have pretty negative feelings about having to press the back button many timesI can relate 😆