6

I have login process like the image below:

enter image description here

the user will be navigated from login screen (in the middle) to change password screen (in the right) using the code below:

 val changePassword = LoginUsingEmailFragmentDirections.actionToChangePasswordFragment()
Navigation.findNavController(fragmentView).navigate(changePassword)

I want if the user successfully change the password, I want to make the user back to login screen programatically.

If I use the old way navigation using a lot of activities, then I usually using finish()

I little bit confused what is the right way to achieve this. do I need to make action first in the graph and then using the similar code like above ? or is there any more convenient or better way to do this ?

Alexa289
  • 8,089
  • 10
  • 74
  • 178

1 Answers1

11

You can navigate up to login screen on button click listener like below:

btn.setOnClickListener{
 Navigation.findNavController(fragmentView).navigateUp()
}
Hussnain Haidar
  • 2,200
  • 19
  • 30