So I have a standard scenario, described in the Android dev docs.
Both fragments are so far pretty much stock from the New | Activity | Basic Activity wizard. I've only slightly changed the first fragment so far to start working on the login credentials.
Basically, after I complete the login, I want to clear my call stack and just move to the main app screen.
This works to some extent for me, by adding:
app:popUpTo="@id/FirstFragment"
app:popUpToInclusive="true"
and then navigating
NavHostFragment
.findNavController(this)
.navigate(R.id.action_FirstFragment_to_SecondFragment);
It works because when pressing the back button / performing the gesture, the app will simply close.
What DOESN'T work, is that now the title bar for the second fragment is showing the back arrow. The back arrow doesn't even work as there's no stack to pop, but still it's there.
I've investigated answers to this question.
I cannot seem to get the FirstFragmentDirections
to build, so I can't try that solution. Tried (unsuccessfully) to modify gradle file and searching for a file that would be built, but not accessible.
I am now left with an arrow that has no place where it's rendered and would appreciate any pointers on how to get rid of it.
Edit1: I have now discovered how to get the FragmentDirections class to be generated. It's described here - all the SO suggestions on the matter lacked the repository inclusion and only mentioned the plugin inclusion.
Edit2: The arrow depends on fragment properties. One of such properties is navigation
's app:startDestination
. It will start the activity on this fragment, but also display the back arrow on all other fragments.
My task has shifted from total non-understanding to seeking how I can specify / override this per-fragment.