如何在Android中启用深层链接?

时间:2015-10-19 21:26:16

标签: android deep-linking

这两个链接都不起作用“ypcc:// test”和“http://ypcc.nl/test”。 它应该打开应用程序。现在ypcc:// test打开游戏商店。

在我的androidManifest中:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "recipe-app://recipes" -->
            <data android:scheme="ypcc"
                android:host="test" />

        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "recipe-app://recipes" -->
            <data android:scheme="http"
                android:host="ypcc.nl"
                android:pathPrefix="/test"/>

        </intent-filter>

    </activity>

有谁知道我错过了什么?

enter image description here 这是一个深层链接扫描应用程序。它给了我这个消息。

1 个答案:

答案 0 :(得分:1)

对于要解析http和https的网址,您需要使用Marshmallow。自定义方案适用于早期的设备。此外,它是路径,而不是 pathPrefix

<activity
    android:name=".MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
        <!-- Accepts URIs that begin with "ypcc://test" -->
        <data android:scheme="ypcc"
            android:host="test" />

    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "http://ypcc.nl/test" -->
        <data android:scheme="http"
            android:host="ypcc.nl"
            android:path="/test"/>

    </intent-filter>

</activity>

如果您想成为链接的唯一处理程序,您可能希望将<intent-filter android:autoVerify="true">添加到intent过滤器,但是您还需要将json文件添加到服务器。

Handling App Links - Google Docs

相关问题