【问题标题】:android apps can't be launched by incoming linksandroid 应用程序无法通过传入链接启动
【发布时间】:2017-09-15 07:36:24
【问题描述】:

我已按照Deep Links to App Content 的教程进行操作。

但是我的应用无法拦截链接。应用根本无法启动。

这是我的 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>

这是我放在我的网络服务器上的测试页 index.html。

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

我已经尝试了几个小时,但仍然无法弄清楚为什么它不起作用。

附:

如果我将方案更改为一些随机的东西,它会起作用。
但是我想拦截http链接。

我也试过改变action、category、data的顺序,没区别。

【问题讨论】:

    标签: android android-intent intentfilter


    【解决方案1】:

    除了 Android 部分之外,您还需要验证您确实被允许在提供 URL 的 Web 服务器上截取给定 URL 的链接。为此,您需要创建一个 JSON 文件并将其上传到给定的 URL(在 .well-known/assetlinks.json 下),其中包含有关您的应用的验证信息,从而有效地允许您的应用拦截链接。

    详情请见https://developer.android.com/training/app-links/verify-site-associations.html

    【讨论】:

    • 抱歉我的粗心。我一步一步地跟着tuts。我觉得你的回答是对的。但是需要一些时间来测试它。我测试后会尽快接受你的回答。
    猜你喜欢
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多