I'm using Jetpack Navigation for deeplinks. Deeplink isn't redirect correctly if the app wasn't opened before. However, if the app exists in memory, the app is coming to the foreground and deeplink is opening correctly. I have 2 activity. One registerActivity the other mainActivity. I want to use deeplinks in fragments in mainActivity.
Is it a bug in Jetpack Navigation or I forgot about something when setting it up?
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.life4.ecommerce">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:name=".ECommerceApplication"
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/Theme.ECommerce"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity android:name=".view.RegisterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.MainActivity"
android:windowSoftInputMode="adjustResize">
<nav-graph android:value="@navigation/nav_main" />
</activity>
</application>
</manifest>
This is the part of a navgraph
<fragment
android:id="@+id/productDetailsFragment"
android:name="com.life4.ecommerce.view.ProductDetailsFragment"
android:label="fragment_product_details"
tools:layout="@layout/fragment_product_details">
<argument
android:name="productID"
app:argType="integer" />
<action
android:id="@+id/action_productDetailsFragment_to_profileFragment"
app:destination="@id/profileFragment" />
<action
android:id="@+id/action_productDetailsFragment_to_imageDetailsFragment"
app:destination="@id/imageDetailsFragment" />
<deepLink
android:id="@+id/deepLink2"
app:uri="example.com/pro/{productID}" />
</fragment>