Reputation: 6675
I'm deep linking (using jetpack navigation) and the logic appears to be working. The problem I'm running into is the logic for activity_discover_detail appears to be blocking the logic for fragment_discover_landing
How would I stop that from happening?
Here's the activity and fragment in question from my nav graph:
<fragment
android:id="@+id/fragment_discover_landing"
android:name="com.my.app.fragments.DiscoverLandingFragment"
android:label="@string/nav_discover_landing"
tools:layout="@layout/discover_landing_fragment">
<action
android:id="@+id/fragment_discover_landing_back_action"
app:popUpTo="@id/fragment_reading_lists"
app:popUpToInclusive="false" />
<argument
android:name="category"
android:defaultValue="Latest"
app:argType="string" />
<argument
android:name="searchText"
app:argType="string" />
<argument
android:name="searchMode"
android:defaultValue="false"
app:argType="boolean" />
<deepLink
android:id="@+id/discover_landing_category"
app:uri="myAppName://discover/category?name={category}" />
</fragment>
<activity
android:id="@+id/activity_discover_detail"
android:name="com.my.app.activities.DiscoverDetailActivity"
tools:layout="@layout/activity_discover_detail">
<argument
android:name="already_handled"
android:defaultValue="true"
app:argType="boolean" />
<deepLink
android:id="@+id/in_app_sell_page"
app:uri="myAppName://discover/{contentId}" />
</activity>
Upvotes: 2
Views: 1536
Reputation: 728
I think that this is happening because myAppName://discover/{contentId}
is more general and contains myAppName://discover/category?name={category}
.
In general you need to make your activity "handle" more specific in order to not shadow the fragment one.
maybe a link like this one would do the trick : myAppName://discover/detail/{contentId}
Also i'm not familiar with the new Navigation Component deep linking,
but i don't see in your code where you define the variable contentId
what is defined within DiscoverDetailActivity
scope is already_handled
, i don't know if that's normal.
EDIT
If you don't have control over the link formats, i'd suggest having a single entry point for deeplinks in your nav graph, than doing the proper parsing, mapping, redirection.
it would be a transparent activity LinkDispatcherActivity
that intercepts all your app links, you can use .*
wildcard to define your links : This <deepLink app:uri="myAppHost://myAppScheme/.*"/>
would match and intercept all links starting with myAppHost://myAppScheme
.
Upvotes: 1