Member-only story
Android Navigation With a Pre-Existing Back Stack
Introducing TaskStackBuilder
Navigating remains one of the most challenging topics in mobile applications. While using navigation components or your own navigator, you’ll find many ways to route to a set of screens.

Navigation also implies how to come back to a previous screen. You must ensure that your user can go back somewhere meaningful to your flow.
With the linear routing above, navigating back from C will land you on B. But what if I asked you to navigate to another screen? Since the Android system handles the back stack, this could seem far-fetched, right?
Let’s assume we want to navigate from A to C without coming from B. Yet, we want the user to land on screen B when navigating back from C — no matter if you came from either A or B.

The Deep Link Use Case
For several projects, I’ve been tasked to implement deep links. In mobile applications, the system can…