Assume you own a website named authorizeme.com and also AuthorizeMe app. For Promotion, you send link of website via Email and you want that link as authorizeme.com/login should open the Login screen in the App on receiver’s phone if App is installed else it should open the login page on Website.
This can be done by handling Web URL as Deep link in the App. Open navigation graph. Select LoginFragment and click on + icon next to Deep Links.
Add following line in URI text field.
www.authorizeme.com/login
Switch to code view and confirm the entry added for LoginFragment.
Go to AndroidManifest.xml and add following line inside mainactivity tags after intent filter:
<nav-graph android:value="@navigation/nav_graph" />
Traditionally, developers used to handle Web URL deep links by specifying details inside Intent Filter such as scheme, host and pathPrefix etc. Now you specify the Navigation graph in AndroidManifest.xml , and Deep links configured in Nav graph takes care of rest.
Also, if deep linked to an intermediate screen, then traditionally back navigation was also required to handle manually. Navigation component now takes care of back navigation for you. Build and run the app to see the Web URL Deep link in Action.
Click back to return to Home screen. Open Google app and type the following web link: www.authorizeme.com/login
Select Open with AuthorizeMe You are taken to **Login **screen as intended.
Now click Back button. It takes you to Home screen. This back navigation is automatically handled by Navigation component and it takes you to the start destination. So cool, isn’t it!