Alex Alex
Alex Alex

Reputation: 131

Android navigation component back stack

i created a nav graph with fragments fragA->fragB->fragC-fragD->fragE->fragF->fragG. From some push notification user must directly go to fragG with findNavController().navigate(R.id.fragG), and when user tap back button he must go to fragF, but now is back to first fragment of navigation graph because fragB->fragC-fragD->fragE->fragF is not added to back stack. It's possible to add this frag to stack when user navigate to last an press back button? Thanks.

Upvotes: 5

Views: 2037

Answers (1)

beigirad
beigirad

Reputation: 5744

It's not an official answer but it works as a workaround.

You can create the back stack manually by navigating sequentially.

fun openGFromPushNotification(){
   navigate(R.id.fragB)
   navigate(R.id.fragC)
   navigate(R.id.fragD)
   navigate(R.id.fragE)
   navigate(R.id.fragF)
   navigate(R.id.fragG)
}

Upvotes: 3

Related Questions