简体   繁体   English

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

[英]How do I enable deep-linking in Android?

Both the links are not working "ypcc://test" and " http://ypcc.nl/test ". 这两个链接都无法正常运行“ ypcc:// test”和“ http://ypcc.nl/test ”。 It should open the app. 它应该打开应用程序。 Now ypcc://test opens the play store. 现在ypcc:// test打开Play商店。

In my androidManifest: 在我的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>

Does anyone know what I missed? 有人知道我错过了吗?

在此处输入图片说明 This is a deep link scanning app. 这是一个深层链接扫描应用程序。 It's giving me this message. 给我这个信息。

For URL parsing of http and https to work, you need to be on Marshmallow. 为了使http和https的URL解析正常工作,您需要使用棉花糖。 The custom scheme works on earlier devices though. 不过,自定义方案在较早的设备上有效。 Also, it's path , not pathPrefix . 另外,它是path ,而不是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>

You may want to add <intent-filter android:autoVerify="true"> to the intent filter if you want to be the only handler for the link, but then you'll also need to add a json file to the server. 如果您想成为链接的唯一处理程序,则可能想在<intent-filter android:autoVerify="true">添加<intent-filter android:autoVerify="true"> ,但是您还需要向服务器添加一个json文件。

Handling App Links - Google Docs 处理应用程序链接-Google文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM