Android官方培训文档翻译(四)——Create App Links for Instant Apps

Create App Links for Instant Apps(为即时应用创建应用链接)

  An Android Instant App is a small version of your app that runs without installation. Instead of installing an APK, users launch your app simply by clicking a URL. As such, all instant apps need to be accessible via a URL declared using Android App Links. This page explains how to use Android App Links for your Android Instant Apps.
  Android即时应用程序是您的应用程序的一个小版本,无需安装即可运行。用户只需点击一个URL即可启动您的应用程序,而无需安装APK。因此,所有即时应用程序都需要通过使用Android应用程序链接声明的URL访问。本页说明如何为您的Android即时应用程序使用Android应用程序链接。

  Note: If you're not building an instant app, then you don't need to read this guide—you should instead create app links for your installable app by reading Create Deep Links to App Content.
  注意:如果您不构建即时应用程序,则无需阅读本指南,而应该通过阅读创建应用程序内容的深层链接来为您的可安装应用程序创建应用程序链接。

App links overview

  First, here's a summary of what you should already understand about app links.

  • When you create an intent filter for activities in your app that allow the user to jump straight to a specific screen in your app with a URL link, this is known as a "deep link." Other apps can declare a similar URL intent filter, though, so the system might ask the user which app to open. To create these deep links, read Create Deep Links to App Content.
  • When you publish an assetlinks.json file on the website that corresponds to your app's HTTP deep links, you verify that your app is the true owner of those URLs. Thus, you've converted your deep links into Android App Links, which ensure that your app instantly opens when the user clicks such a URL. To create app links, read Verify Android App Links.

  首先,这里是你应该已经了解的应用程序链接的总结。 当您为应用中的活动创建一个意图过滤器,允许用户使用URL链接直接跳到应用中的特定屏幕时,这被称为“深层链接”。其他应用程序可以声明一个类似的URL意图过滤器,所以系统可能会要求用户打开哪个应用程序。要创建这些深层链接,请阅读创建应用程序内容的深层链接。 当您在与您的应用的HTTP深层链接对应的网站上发布assetlinks.json文件时,请确认您的应用是这些网址的真正所有者。

  So, Android App Links are simply HTTP deep links that your website is verified to own so that the user doesn't need to choose which app to open. For a more specific description, see differences between deep links and app links.
  因此,您已将深层链接转换为Android应用链接,这可确保您的应用在用户点击此类网址时即时打开。要创建应用链接,请阅读验证Android应用链接。 所以,Android应用程序链接只是HTTP深层链接,您的网站被验证拥有,以便用户不需要选择要打开的应用程序。有关更详细的说明,请参阅深层链接和应用链接之间的差异。

  In both cases, however, the user must already have your app installed. If the user clicks one of your web site's links and they don't have your app installed (and no other app handles that URL intent), the URL is opened in a web browser. So, creating an Instant App solves this part—it allows users to open your app by simply clicking a URL, even if they don't have your app installed.
  但是,在这两种情况下,用户必须已经安装了您的应用程序。如果用户点击您的某个网站的链接,但没有安装您的应用程序(并且没有其他应用程序处理该URL意图),则会在网络浏览器中打开该URL。因此,创建一个即时应用程序解决了这一部分 - 它允许用户通过简单地点击一个URL来打开您的应用程序,即使他们没有安装您的应用程序。

  When end users perform a Google search for your app, Google Search displays a URL with the "Instant" badge.
  当最终用户为您的应用执行Google搜索时,Google搜索会显示带有“即时”徽章的网址。

How app links for instant apps are different (即时应用程序的应用程序链接有何不同)

  If you've already followed the guides to Create Deep Links to App Content and Verify Android App Links, then you've already done most of the work necessary to make app links work with your instant app. There are just a couple extra rules when using app links for instant apps:
  如果您已经按照指南创建应用内容的深层链接并验证Android应用链接,那么您已经完成了使应用链接与即时应用一起工作所需的大部分工作。使用即时应用程序的应用程序链接时,只有一些额外的规则:

  • All intent filters used as app links in your instant app must support both HTTP and HTTPS. For example:
    在即时应用程序中用作应用程序链接的所有意图过滤器必须同时支持HTTP和HTTPS。例如:

    
    
    
    
    

  Notice that you don't need to include the host in the second element because, within each element, all combinations of each attribute are considered valid (so this intent filter does resolve https://www.example.com).
  请注意,您不需要在第二个元素中包含主机,因为在每个元素中,每个属性的所有组合都被认为是有效的(因此,此意图过滤器将解析https:/ /www.example.com)。

  • Only one instant app can be declared for each website domain. (This is unlike when creating app links for your installable app, which allows you toassociate a website with multiple apps.)
      每个网站域只能声明一个即时应用程序。 (这与为可安装应用程序创建应用程序链接不同,它允许您将网站与多个应用程序相关联。)

Other reminders when creating app links (其他提醒时创建应用程序链接)

  • All HTTP URL intent filters in your instant app should be included your installable app. This is important because once the user installs your full app, tapping a URL should always open the installed app, not the instant app.
  • You must set autoVerify="true" in at least one intent filter in both the instant and the installable app. (See how to enable automatic verification.)
  • You must publish one assetlinks.json for each domain (and subdomain supported by your app links, using the HTTPS protocol. (See how tosupport app linking for multiple hosts).
  • The assetlinks.json file must be valid JSON, be served without redirects, and be accessible to bots (your robots.txt must allow crawling/.well-known/assetlinks.json).
  • Use of wildcards in your intent filter's host attribute is not recommended. (See how to support app linking from multiple subdomains.)
  • Custom host/scheme URLs should be declared with separate intent filters.
  • Ensure that your app link URLs account for your top search results for your key terms.

  即时应用程序中的所有HTTP URL意图过滤器都应该包含在您的可安装应用程序中。这一点很重要,因为一旦用户安装完整的应用程序,点击一个URL应该总是打开已安装的应用程序,而不是即时应用程序。

  • 您必须在即时和可安装应用中的至少一个意图过滤器中设置autoVerify =“true”。 (请参阅如何启用自动验证。)
  • 您必须为每个域(和您的应用程序链接所支持的子域,使用HTTPS协议)(请参阅如何支持多个主机的应用程序链接)发布一个assetlinks.json。
  • assetlinks.json文件必须是有效的JSON,没有重定向,并且可以被漫游器访问(您的robots.txt必须允许抓取/.well-known/assetlinks.json)。
  • 不建议在意图过滤器的主机属性中使用通配符。 (请参阅如何支持来自多个子域名的应用链接。) 自定义主机/方案URL应使用单独的意图过滤器进行声明。
  • 确保您的应用链接网址符合您的关键字词的顶级搜索结果。

你可能感兴趣的:(Android官方培训文档翻译(四)——Create App Links for Instant Apps)