Android 深层链接在我链接的应用程序中打开,而不是启动我的应用程序的单独实例
Android deep links opens in the app I linked from instead of launching a separate instance of my app
我正在使用本机反应。深度 linking 对 ios 非常有用。但是,对于 Android,我似乎无法弄清楚如何从深层 links 正确打开我的应用程序。
当从 link 中打开深度 link 时Firefox,我的应用程序是在 firefox window 中启动的。当我使用深度 link-tester 应用程序时也是如此。一切都按预期与应用程序一起工作,但它不是从正确的应用程序启动的。
我做错了什么?这是我的 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>
看看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:
尝试将 android:launchMode="singleTask"
放在您的 activity 标签上
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
进一步的背景阅读包括(以及您可以尝试的许多其他内容):
FLAG_ACTIVITY_NEW_TASK clarification needed
Android Task Affinity Explanation
我正在使用本机反应。深度 linking 对 ios 非常有用。但是,对于 Android,我似乎无法弄清楚如何从深层 links 正确打开我的应用程序。
当从 link 中打开深度 link 时Firefox,我的应用程序是在 firefox window 中启动的。当我使用深度 link-tester 应用程序时也是如此。一切都按预期与应用程序一起工作,但它不是从正确的应用程序启动的。
我做错了什么?这是我的 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>
看看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:
尝试将 android:launchMode="singleTask"
放在您的 activity 标签上
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
进一步的背景阅读包括(以及您可以尝试的许多其他内容):
FLAG_ACTIVITY_NEW_TASK clarification needed
Android Task Affinity Explanation