2

在我的应用程序中,我想使用deeplink。在启动器intent-filter中添加深度链接时,应用程序图标消失在应用程序抽屉中! 但是当将deeplink显示应用程序图标删除到应用程序抽屉时activity
intent-filter

清单代码:

<activity android:name=".Pages.Splash.SplashPage">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        <!-- DeepLink -->
        <action android:name="android.intent.action.VIEW" />

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

        <data
            android:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

    </intent-filter>
</activity>

使用上述代码时,不在应用程序抽屉中显示应用程序图标,而是从manifest显示图标中删除以下代码时。

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

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

        <data
            android:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

我想当打开的用户点击链接时,首先启动启动activity,然后动态打开另一个activity

我该如何解决?

4

1 回答 1

7

您应该创建两个单独的意图过滤器。在您的标签中尝试以下代码<activity/>

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

    <!-- DeepLink -->
    <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:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

    </intent-filter>

最后,您的代码将如下所示:

<activity android:name=".Pages.Splash.SplashPage">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

    <!-- DeepLink -->
    <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:host="www.example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />
        <data
            android:host="example.com"
            android:pathPrefix="/gaming"
            android:scheme="http" />

    </intent-filter>
</activity>
于 2018-11-27T08:23:48.687 回答