0

I am new to android and In my android project i am making an API call when user presses button to get OTP and if the response from server is successful i am navigating the user to another screen where he could submitt the OTP.problem arises when i presses back button ,since i am observing the livedata and that livedata is still in success state hence user goes back and immediately get navigated to the current screen(making it feel user stayed on same screen).Please help how can i solve this problem.

PiyushSharma
  • 9
  • 1
  • 2
  • 1
    Does this answer your question? [How to clear LiveData stored value?](https://stackoverflow.com/questions/44582019/how-to-clear-livedata-stored-value) – jeprubio Aug 22 '22 at 10:09
  • 1
    Check that message of ways to deal with it with live data, however I would recommend using StateFlow value when that view state (the value that causes navigating) is consumed – jeprubio Aug 22 '22 at 10:17

0 Answers0