gpt4 book ai didi

android - 深层链接不会打开新应用

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:17:20 26 4
gpt4 key购买 nike

我有两个应用程序。从第一个开始,我想通过深度链接启动第二个。它有效,但问题是第二个开始于第一个。我想在一个新实例中开始第二个。

第一个应用打开第二个应用的代码:

String uri = "deeplinkTestTom://token/123456";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);

第二个应用程序的 list :

 <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data

android:scheme="deeplinkTestTom" />

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>

当我尝试从我的第一个应用程序 (String uri = "facebook://facebook.com/inbox";) 启动 Facebook 应用程序时,它会在一个新应用程序中启动 facebook,而不是在我的应用程序中第一个应用程序。所以我想我的第二个应用程序的 list 中有些东西是 missig,但我找不到什么。

我该怎么办?

最佳答案

我相信您是在谈论新的 Task 而不是“新应用”。

阅读Tasks and Back Stack

您需要使用 Intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 在新的 Task 中启动 Activity

对于你的情况,使用

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

关于android - 深层链接不会打开新应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32133601/

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