gpt4 book ai didi

Android 深层链接在我链接的应用程序中打开,而不是启动我的应用程序的单独实例

转载 作者:行者123 更新时间:2023-12-03 23:21:04 26 4
gpt4 key购买 nike

我正在使用 native react 。深度链接非常适合 ios。然而,对于 Android,我似乎无法弄清楚如何从深层链接正确打开我的应用程序。

从例如打开深层链接时Firefox,我的应用程序在 Firefox 窗口内启动。当我使用深度链接测试器应用程序时也是如此。除了不是从正确的应用程序启动之外,该应用程序的一切都按预期工作。

我究竟做错了什么?这是我的 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

关于Android 深层链接在我链接的应用程序中打开,而不是启动我的应用程序的单独实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57752778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com