I've been practicing for a while with the Navigation component in Android and I would like to know what is the best way to perform a conditional initial navigation, depending on a specific state.
For example, in a social network like Instagram, the user is redirected to his home or login at the start, depending on whether he is currently logged in or not.
In the official Android documentation about Conditional navigation, they explain how to redirect the user to login if, once the user has accessed a specific part of the app, he is not currently logged in. Although this solution could help, I don't know if in my case it is completely correct since it would briefly show the home before the user was redirected to the login.
I found a post here on StackOverflow, in which a user asks a related question. Although there is not an answer, nor do the comments end up fully answering him.
What I tried
I already try to implement a conditional navigation by separating into two graphs, the authentication flow (Login in the example) and my main application flow (Home in the example). In this way, when starting my main activity, I can add one graph or another, depending on whether the user is logged in or not.
This solution seems to work fine, although when the Android system removes the app from memory, my navigation doesn't seem to restore correctly.
*I have to mention that to complete this task, I am not using Compose, so solutions that use it will not work for me. Answers based on multiple activities, obviously, won't work for me either.