为什么在使用自定义主机和架构时Deeplink无法正常工作?

时间:2019-06-25 02:33:32

标签: android html kotlin deeplink

我正在尝试通过单击浏览器中的链接来打开我的应用程序。当我在测试站点尝试使用以下主机和架构时,其工作正常并获得了pathPrefix。我只是将主机更改为我的应用程序而已,并且无法正常运行并将其加载到浏览器中。

我从某个网站尝试过的

     android:host="dolap.com"
     android:scheme="https"
     android:pathPrefix="/id"/>

和html标签在这里

<a href="https://www.dolap.com/id=1001">Visit our HTML tutorial</a>

我使用的服务器主机是

     android:host="ledhis.in"
     android:scheme="https"
     android:pathPrefix="/id"/>

和html标签在这里

<a href="https://www.ledhis.in/id=1001">Visit our HTML tutorial</a>

1 个答案:

答案 0 :(得分:1)

您的代码还不够。所以不能说你到底在哪里有问题。

阅读并遵循以下说明:https://medium.com/@muratcanbur/intro-to-deep-linking-on-android-1b9fe9e38abd

我按照以下步骤进行,一切正常。 如果您有任何问题,请告诉我

更新

将此代码添加到清单文件到该活动中,该活动将收到深度链接调用:

 <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:scheme="http"
                android:host="www.example.com"
                android:pathPrefix="/gizmos" />
        </intent-filter>

然后添加意图检查:

Intent intent = getIntent();
Uri data = intent.getData();

在视图中添加一个按钮,该按钮将共享您的链接,以便您可以对其进行测试。 甚至您将如何测试它。在您的代码中没有发现任何测试逻辑。

还要检查这2个链接:

第1部分:https://android.jlelse.eu/deep-linking-in-androd-9c853573fdf4

第2部分:https://android.jlelse.eu/deep-linking-in-android-part-2-23e942293032