5

I am using Navigation Component to handle navigations, but when use popBackStack() or onBackPressed() to back to previous fragment my onViewCreated call again in fragment with api and set up views.
Since Navigation Component 2.4 unveiled new features (popUpToSaveState and restoreState), i want to use it. please tell me how?

reza_khalafi
  • 6,230
  • 7
  • 56
  • 82

1 Answers1

-2

Even though you save your state onViewCreated will be called.

you need to use to save state.

override fun onSaveInstanceState(outState: Bundle) {
    super.onSaveInstanceState(outState)
}

and restore it on onCreate.

vignesh
  • 492
  • 3
  • 9