简体   繁体   English

传入链接无法启动android应用

[英]android apps can't be launched by incoming links

I have followed tutorials from Deep Links to App Content . 我遵循了从深层链接到应用程序内容的教程。

However my app can't intercept the links. 但是我的应用程序无法拦截链接。 The app can't be launched at all. 该应用程序根本无法启动。

Here is part of my Android manifest: 这是我的Android清单的一部分:

<activity android:name=".MainActivity">
        <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.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
            <data android:scheme="http"
                  android:host="www.example.com"
                  android:pathPrefix="/gizmos" />
            <!-- note that the leading "/" is required for pathPrefix-->
        </intent-filter>

    </activity>

Here is the test page index.html i put on my web server. 这是我放在Web服务器上的测试页index.html。

<a id="applink1" href="http://www.example.com/gizmos/sss">    
Open Application</a>    

I have tried hours and still can't figure out why it doesn't work. 我已经尝试了几个小时,但仍然不知道为什么它不起作用。

Ps: PS:

If I change scheme to some random stuff, it will work. 如果我将方案更改为一些随机的东西,它将起作用。
However I want to intercept the http link. 但是我想拦截http链接。

I also tried change the order of action, category, data, it makes no difference. 我还尝试过更改操作顺序,类别,数据,这没有什么区别。

Additionally to the Android portion, you need to verify that you are indeed allowed to intercept links for the given URL on the web server serving the URL. 除了Android部分之外,您还需要验证是否确实允许您在服务URL的Web服务器上拦截给定URL的链接。 To do that, you need to create and upload a JSON file to the given URL (under .well-known/assetlinks.json ) that contains verification information about your app, effectively allowing your app to intercept links. 为此,您需要创建一个JSON文件并将其上传到给定的URL(在.well-known/assetlinks.json ),该文件包含有关您的应用的验证信息,从而有效地允许您的应用拦截链接。

See https://developer.android.com/training/app-links/verify-site-associations.html for the details. 有关详细信息,请参见https://developer.android.com/training/app-links/verify-site-associations.html

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

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