[译]Android6.0新特性:App Links

作者: 于连林520wcf | 来源:发表于2016-05-12 14:26 被阅读2940次

    AppLinks允许开发者将app和他们的web域名关联。这一举措是为了最小化用户遇到“打开方式”对话框的概率。

    今天上午没什么活,在YouTube上看了一段Android6.0新特性的视频,
    Youtube地址
    为了让没有梯子的同学方便观看,我上传了一份放到优酷
    由于涉及到版权问题,让我感到深深自责,在未来的某段时间,优酷上的视频我会撤销。

    视频是英文的,下面是视频字幕和我的翻译,有翻译不恰当的地方多多指正啊。

    视频内容

    So let's say you have a website, and you also built an app for a more seamless experience on mobile.
    这么说, 假如你有一个网站, 你可以更加无缝的启动你的内置应用程序。

    As people share and follow web links to your content on Android, they will normally see this speed bump that we call a disambiguation dialogue.
    随着人们分享,并按照连接到您的网页内容,在Android系统中,他们通常会看到下面这样的选项,我们通常称之为歧义对话框。

    歧义对话框

    It's shown when the user has many apps on their device which can handle the same type of link,in this case, one containing your domain and the URL.
    当用户在其设备上装了许多可以处理相同连接的应用(包含同样的域名或者URL),就会显示上面这种对话框。

    But wouldn't it be great if users who follow a link to a website that you own get sent directly to your app?
    但这不是很好,如果用户遵循一个链接到一个网站,能让他直接发送到你的应用吗?

    My name is Wojtek kalicinski,and I'll show you how app links, a new feature in Android Marshmallow, lets you do just that.
    我的名字是Wojtek kalicinski,我将向您展示如何使用app links。这是Android6.0中的一个新特性,可以让您做到上面这一点。

    Now , there are two conditions an app needs to meet in order to get rid of this disambiguation dialogue for good.
    现在,有两个app 需要摆脱歧义对话框。
    One, it has to be configured to handle URLs pointing to your website.
    一,它必须被配置为处理URL指向你的网站。
    And two, you must be able to prove that you control the domain under which your site is hosted.
    第二,你必须能够操作你的网站空间。

    Let me show you how to do it.
    让我告诉你如何做到这一点

    First, look at your Android manifest file and make sure that you have at least one activity with an intent filter that matches the following.
    首先, 看看你的清单文件并确保你至少有一个Activity与下面的匹配


    清单文件配置

    For the data element,it uses an HTTP or HTTPS scheme with your domain as ths host.
    对于数据元素, 它使用Http或HTTPS约束与您的域名作为主机。

    It also needs to have a view action and the browsable category.
    它也需要一个View action和BROWSABLE的category。

    if you've implemented deep linking in your app before,you might notice that you have that part configured already.
    如果你以前在你的应用实现深层连接,你可能会发现你有部分已配置。

    There's one more detail you need for enabling app links,though,and that's the new autoVerify attribute.
    还有一个细节,你需要启用app links,这是新的autoVerify(自动检验)属性。

    autoVerify属性

    So make sure you add this as well.
    所以一定要添加这一点
    This will tell the system to kick off domain verfication when your app is installed.
    这将告诉系统自动验证你的app是否安装。

    Let me walk you through that last step now.
    让我带您完成这最后一步了。

    In order to associate your site with your app,you will need to put a digital asset links JSON file on this exact path under your websites's root directory.
    为了您的网站与您的应用关联,您将需要把assetlinks.json文件放在你的网站的根目录下的这个路径。


    文件路径

    The format of ths file is pretty straightforward.
    这个文件的格式很简单。
    You can just copy the sample from our documentation and replace the two highlighted values with your apps package name and the fingerprint of your sighning certificate.
    你可以从我们的文档中复制,把将两个突出显示的值替换为你的应用程序包名和签名。


    assetlinks.json
    You should leave the other fields exactly as shown here.
    你应该确切保留其它字段,如这(图中)所示。

    Be careful if you're using a different certificate or package name for your debug build,or you will run info problems later.
    一定要注意, 如果你测试的时候使用的不同签名或者包名,稍后正式运行的时候会遇到问题。

    Also, make sure the file you create is accessbile over HTTPS as that's the only way Android will be able to successfully verify the connection.
    此外,确保创建的文件通过HTTPS进行访问,因为这是Android操作系统成功验证连接的唯一方式。

    Now, how do you test if everything is working properly?
    现在,你如何测试是否一切正常呢?
    Just install your app on the device like you normally would using adb,Android Studio,or any other method.
    在设备上安装应用程序,就像你通常使用的adb,Android Studio或任何其它方法。
    Then tap on the link to your website from any app.
    然后从任何应用上点击连接到你的网站。
    Or you can issue a command through adb that will start the appropriate intent.
    或者你可以通过adb命令开启适当的意图。


    adb命令

    Observe what happens next.
    观察接下来会发生什么。

    if you set up both parts -- the intent filters and the JSON file -- correctly, your app should launch immediately.
    如果你设置的两个部分——意图过滤器和JSON文件正确,应用程序应该立即启动。

    if you do see a disambiguation dialogue,that means the package installer wasn't able to verify your domain.
    如果你看到一个歧义的对话框,这意味着包安装程序无法验证您的域名。

    You can use the digital asset links tool to see if your JSON file is reachable and parsed correctly.
    您可以使用asset links工具,看看你正确地访问和解析JSON文件。

    With these simple steps, you can make life easier for your users.
    有了这些简单的步骤,就可以让你的用户体验更好。

    So go and implement app links now, or check out the other great features that we're introducing in Android Marshmallow。
    现在去实现应用程序的链接,或者查看其他Android6.0伟大的特性。

    Thanks for watching.
    谢谢观看。


    想学习AppLinks可以参考这篇文章
    https://chris.orr.me.uk/android-app-linking-how-it-works/
    中文
    http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0609/3022.html

    更多精彩请关注微信公众账号likeDev,公众账号名称:爱上Android。

    likeDev.jpg

    相关文章

      网友评论

      本文标题:[译]Android6.0新特性:App Links

      本文链接:https://www.haomeiwen.com/subject/bktprttx.html