首页 > 解决方案 > 在接收器之外的 App Link 中打开应用程序

问题描述

使用 App Links 时,接收者应用程序(EX. Whatsapp)会暂停,并且您的应用程序的活动会在接收者应用程序之上打开。

例如,如果您从 WhatsApp 的聊天页面打开链接,则不会从您的应用程序中打开新活动(最近应用程序中的 WhatsApp 任务包括您的应用程序),而您的应用程序不在最近任务中。

但是如果我想在一个新任务中打开我的应用程序怎么办?与接收方应用程序分开?

这是我从应用链接打开的活动的清单文件:

    <activity
        android:name=".Activitys.MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter
            android:autoVerify="true"
            android:label="@string/app_name">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="eventtk.uae-dc.com"
                android:pathPrefix="/product/"
                android:scheme="https" />
        </intent-filter>
    </activity>

有什么我应该添加到 IntentFilter 的吗?

标签: javaandroid

解决方案


不确定我是否正确理解您想要实现的目标,但您可以尝试添加

android:launchMode="singleTask"

到您的活动定义。

更多信息在这里: https ://inthecheesefactory.com/blog/understand-android-activity-launchmode/en


推荐阅读