Dynamic Feature navigation with Deep Links on Android

tl;dr; There is a way to use deep linking for dynamic feature modules and prevent a chooser from popping up.

Dynamic Feature Navigation

Let’s imagine for a minute we are working on an Android app for selling robot parts. And from a list of parts in the app, we want to go to a details page of a specific part. For this we created a PartDetailsActivity. Now to navigate to this Activity using an Intent we have several options in Android. At first we might use the tried and tested way of directly using the Activity name in the Intent. Like this:

Finding a solution

So let’s go and Sherlock Holmes our way out of this.

App Bundles Sample App showing chooser

The Fix

Now, could we somehow fix this?

The name of the Activity the ResolverActivity will start

Conclusion

With this in place, it should now be possible to use the same method of navigation in your app for everything. Like external links, Instant Apps, Dynamic Feature and maybe even your iOS app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store