title: Deep Link Using Android Navigation Component Opens Incorrect Screen
body: <p>Hi I'm learning how to use Android's Navigation Component and as part of that I'm making a very basic practice app to try stuff out. I've got basic navigation and data transfer between two screens set up but the part I'm stuck on is setting up a deep link. Currently I've put a deep link tag in a destination (fragment) that currently can't be reached in any other way. This is basically a third screen separate from the other two connected screens and the deep link is the only way to access it. </p>
  
  <p>I've shared my navigation xml file below as well as my manifest. </p>
  
  <p>Here is the navigation file, the relevant bit is the last fragment tag creatively named "firstDeepLinkFragment".</p>
  
  <pre class="lang-xml prettyprint-override"><code>
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/navigation_graph"
      app:startDestination="@id/firstFragment"&gt;
  
      &lt;fragment
          android:id="@+id/firstFragment"
          android:name="android.bignerdranch.navcontrollertest.FirstFragment"
          android:label="navigation_first_fragment"
          tools:layout="@layout/navigation_first_fragment" &gt;
          &lt;action
              android:id="@+id/action_firstFragment_to_secondFragment"
              app:destination="@id/secondFragment"
              app:enterAnim="@anim/nav_default_enter_anim"/&gt;
      &lt;/fragment&gt;
  
      &lt;fragment
          android:id="@+id/secondFragment"
          android:name="android.bignerdranch.navcontrollertest.SecondFragment"
          android:label="navigation_second_fragment"
          tools:layout="@layout/navigation_second_fragment" /&gt;
  
      &lt;fragment
          android:id="@+id/firstDeepLinkFragment"
          android:name="android.bignerdranch.navcontrollertest.FirstDeepLinkFragment"
          android:label="first_deeplink_fragment"
          tools:layout="@layout/first_deeplink_fragment" &gt;
          &lt;deepLink
              android:id="@+id/deepLink"
              app:uri="example://gizmos" /&gt;
      &lt;/fragment&gt;
  &lt;/navigation&gt;
  </code></pre>
  
  <p>&nbsp;</p>
  
  <p>Here's the manifest. </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="android.bignerdranch.navcontrollertest"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
  
              &lt;nav-graph android:value="@navigation/navigation_graph"/&gt;
  
  
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>&nbsp;</p>
  
  <p>So from my understanding of how deep links work under the Navigation Component, all I have to do is add the deep link tag to the destination I want to link to, establish the URI as an attribute of that tag, and then add the nav-graph tag in the manifest and point it to the right navigation graph file. If I set that stuff up right I should have a proper deep link set up and good to go. The problem is that when I enter the following command to test the deep link <code>adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos/"</code> it instead opens the default activity, or rather the default destination (which is a fragment like every other destination I've set up here). </p>
  
  <p>&nbsp;</p>
  
  <p>I'm honestly not sure where I may have gone wrong and there isn't a ton of information out about this right now so I was hoping for some advice from people who have already tinkered around with this. I know the old way to set up deep links involved writing intent filters in the manifest under the activity tag  of the activity we wanted to link to. But under the framework of the Navigation Component we now only have one main activity and all our other screens/destinations are fragments. And since fragments don't have to be (and maybe shouldn't/can't be?) registered in the manifest I don't know how I could even set up a deep link with the old methodology. </p>
  
  <p>&nbsp;</p>
  
  <p>So yeah if anyone could help steer me in the right direction, point out any silly mistake I may have made, or clear up a misunderstanding I would really appreciate it. Thank you.</p>