1

I am struggling to figure out the correct architecture for a pretty simple app using the navigation component. I basically have a splash screen that checks if the user has a valid token and then either sends to the main fragment or the login fragment. The problem is that if I send to the login fragment, the back button allows the user to go to the main fragment. I have looked into disabling the back button, but that seems hacky. Do I need to set up 2 activities with 2 different nav graphs? or is there a cleaner way to do this?

D Myers
  • 61
  • 4

2 Answers2

0

In this case the best solution is to use Double press back to exit app Use this solution in your main fragment to achieve the double back to exit.

MohanKumar
  • 494
  • 3
  • 20
0

answer

I was able to follow the example. The key is using the action to navigate and set the popTo and inclusive appropriately. After doing this, the back button closes the app instead of navigating to the main fragment.

D Myers
  • 61
  • 4