0

The two screens relevant to my issue amount to MainFragment (a master view) and ProfileFragment (a detail view). The launch path from login -> main -> profile works fine. The return path isn't working as well. I get stranded at main when navigating backward with via gesture or device button.

On the initial "back" from the profile, I'm returned to main and see main's onViewCreated, onResume lifecycles. I expect back from main would return to login or even exit the app, but instead it reloads main a dozen times before crashing.

For any subsequent "back" from main, the logs reveal main's onAttach, onCreate, onViewCreated, onResume lifecycles recurring each time. This seems suspicious although it's a pretty vanilla navigation graph, a single Activity hosting four basic Fragments. They're all navigated with basic actions using their generated, type-safe Directions classes. I haven't overridden onBackPressed in any of these classes.

Combinations of app:popUpTo="@+id/loginFragment" and/or app:popUpToInclusive="true" haven't helped.

Do I need to implement back or "up" in order to work as expected? Any thoughts are appreciated.

nav_graph.xml

es0329
  • 1,366
  • 1
  • 18
  • 35

1 Answers1

0

On closer inspection, it's working the way it's coded. Of course it is!

The preceding LoginFragment checks a SharedPreference value and navigates to main. I confirmed that happens so quickly I thought I never returned to login screen, when in fact I did.

I'll investigate removing login screen from the stack after authentication.

es0329
  • 1,366
  • 1
  • 18
  • 35