繁体   English   中英

android-app链接不起作用

[英]android-app link not working

我正在关注 Google I/O 2015 中的这个示例。
演示网站: http://recipe-app.com/recipe/grilled-potato-salad演示应用: http://search-codelabs.appspot.com/codelabs/android-deep-linking

我的测试:
我已经从上面的链接安装了演示应用程序。 我使用谷歌搜索应用程序对“烤土豆沙拉”进行了谷歌搜索,发现http://recipe-app.com/recipe/grilled-potato-salad
我希望单击链接会直接打开应用程序,而不是消歧对话框( http://search-codelabs.appspot.com/img/android-deep-linking/img-5.png )。 但是,消歧对话框仍然让我感到惊讶。

那网站上的<link rel="alternate" href="android-app://com.recipe_app/http/recipe-app.com/recipe/grilled-potato-salad" />不是没用吗?

应用的清单文件:
```

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/CustomActionBarTheme" >

    <activity
        android:name=".client.HomeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".client.RecipeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <intent-filter android:label="@string/app_name">
            <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://recipe-app.com/recipe" -->
            <data android:scheme="http"
                android:host="recipe-app.com"
                android:pathPrefix="/recipe" />
        </intent-filter>
    </activity>

    <provider
        android:name=".client.content_provider.RecipeContentProvider"
        android:authorities="com.recipe_app" >
    </provider>
</application>

```

那个教程确实已经过时了。
HTML 标记确实没用。

Google 搜索结果与深层链接一起使用所需要的是按照此处的说明在您的生产网络服务器上有一个公开的https://<yoursite>/.well-known/assetlinks.json文件:
为您的应用程序设置 URL 支持后,应用程序链接助手会生成一个数字资产链接文件,您可以使用它来将您的网站与您的应用程序相关联。

作为使用数字资产链接文件的替代方法,您可以在 Search Console 中关联您的网站和应用。

要使用 App Links Assistant 关联您的 App 和您的网站,请单击 App Links Assistant 中的 Open the Digital Asset Links File Generator,然后按照以下步骤操作:

App Links Assistant 将引导您完成基本的 URL 映射 图 2. 输入有关您的站点和应用程序的详细信息以生成数字资产链接文件。

  1. 输入您的站点域和您的应用程序 ID。 2) 要在您的数字资产链接文件中包含对密码 Smart Lock 的支持,请选择支持在应用程序和网站之间共享凭据并输入您网站的登录 URL。 这会将以下字符串添加到您的数字资产链接文件,声明您的应用程序和网站共享登录凭据:delegate_permission/common.get_login_creds。 详细了解如何在您的应用中支持 Smart Lock for Passwords。 3) 指定签名配置或选择一个密钥库文件。 确保为应用程序的发布版本或调试版本选择正确的配置或密钥库文件。 如果要设置生产版本,请使用发布配置。 如果要测试构建,请使用调试配置。 4) 单击生成数字资产链接文件。 5) Android Studio 生成文件后,单击“保存文件”进行下载。 6) 将 assetlinks.json 文件上传到您的站点,每个人都具有读取权限,位于 https:///.well-known/assetlinks.json。 重要提示:系统通过加密的 HTTPS 协议验证数字资产链接文件。 确保 assetlinks.json 文件可通过 HTTPS 连接访问,无论您的应用程序的 Intent 过滤器是否包含 https。

  2. 单击链接并验证以确认您已将正确的数字资产链接文件上传到正确的位置。

您现在应该能够看到您的应用 -已安装在 Google 搜索结果中,这就是您知道它已运行的方式

尝试使用

<intent-filter tools:node="merge" android:autoVerify="true">

Intent-filter 标签中的 autoverify 告诉 Android 检查网站和应用程序是否具有相同的公共所有者,这是应用程序链接所必需的(否则,它只是深层链接,这就是您看到消歧对话的原因)。

<intent-filter android:label="@string/app_name" android:autoVerify="true" >
<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://recipe-app.com/recipe" -->

<data android:scheme="http"
  android:host="recipe-app.com"
  android:pathPrefix="/recipe" />
</intent-filter>

现在,尝试先在您设备的“默认浏览器”上打开链接,默认浏览器通常是 Google 搜索。 有时,由于不同的原因,应用程序链接可能无法在 Chrome 或其他一些应用程序中使用。

如果您已经熟悉深度链接,您还可以参考此链接https://developer.android.com/training/app-links/了解如何让您的网站 url 重定向到用户手机上的应用程序(如果它已安装。如果没有,请参阅“Instant Apps-Android”)。

如果您已成功集成所有步骤并且您的链接已验证连接到您的活动但仍未触发应用程序的活动,则 go 到应用程序的设置并启用深度链接,然后 select 您提供的链接。 一旦您在 Play 商店中更新发布版本,这将自动启用。

暂无
暂无

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

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