Reputation: 478
I am using react-native. Deep linking is working great for ios. For Android however, I can't seem to figure out how to open my app properly from deep links.
When opening a deep link from e.g. Firefox, my app is launched inside the firefox window. It is the same when I use a deep link-tester app. Everything works as intended with the app with the exception that it is not launched from the proper app.
What am I doing wrong? Here is an excerpt from my AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
Upvotes: 14
Views: 5637
Reputation: 76506
Take a look at https://developer.android.com/guide/components/activities/tasks-and-back-stack
When declaring an activity in your manifest file, you can specify how the activity should associate with a task using the element's launchMode attribute.
The launchMode attribute specifies an instruction on how the activity should be launched into a task. There are four different launch modes you can assign to the launchMode attribute:
Try putting android:launchMode="singleTask"
on your activity tag
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.
https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks
Further background reading includes (and many other things you can try):
FLAG_ACTIVITY_NEW_TASK clarification needed
Android Task Affinity Explanation
Upvotes: 29