添加 Android App Links

马肤
这是懒羊羊

添加 Android App Links功能

  • 介绍
    • 一个简单的效果
    • Android配置
      • Add Url intent filters
      • Add logic to handle the intent
      • Associate website
      • 搭建网页支持AppLinks

        介绍

          Android App Links 是指将用户直接转到 Android 应用内特定内容的 HTTP 网址。Android App Links 可为您的应用带来更多流量,帮助您发现最常用的应用内容,并让用户更轻松地在已安装的应用中查找和分享内容。

        一个简单的效果

        //TODO 添加视频

        我们在网页上输入:http://tobey-r1.github.io/tobey?23

        然后效果如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第1张

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第2张

        Android配置

          在Android studio编译器里面顶部的Tools里面的App Links Assistant里面就是给你的app添加link配置的步骤,包括最后的url测试。麻烦点在于如果自己只是研究且测试需要一个网页去支持和app的绑定,这就是下一个流程要说的。Android上面的配置就比较简单了,大概是这样的:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第3张

          按照前面三个步骤来。

        Add Url intent filters

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第4张

          这里pathPattern就是host之后的匹配内容了,对应上才能link到app上面去。

        Add logic to handle the intent

          就是接受外部网页传递的参数intent,data之类的(点击insert code会自动插入到页面上去):

        // ATTENTION: This was auto-generated to handle app links.
                val appLinkIntent: Intent = intent
                val appLinkAction: String? = appLinkIntent.action
                val appLinkData: Uri? = appLinkIntent.data
                //简单打印下
                "数据$appLinkData".printLog()
                "action$appLinkAction".printLog()
        

        Associate website

          这步是关键:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第5张

        生成的json文件保存到本地之后我们后面要把它放到网页的对应(.well-known)目录下,访问效果如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第6张

        然后我们点击Link and Verify报错也没关系,因为目前网页上我们还没加上这个json文件呢。

        搭建网页支持AppLinks

          需要你有一个GitHub账户即可,我们通过github提供的GitHub Pages功能自己建一个简单的静态链接,以下是我最终搞好的一个可以测试的github项目。静态网址是:https://tobey-r1.github.io/ 效果如下(网上随便找的一个模板):

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第7张

        对应的Digital Asset Links网址:https://tobey-r1.github.io/.well-known/assetlinks.json运行效果如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第6张

        然后applink的测试只需要在浏览器里面输入:http://tobey-r1.github.io/tobeyxxx如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第9张

          打开我创建的github仓库之后,大致如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第10张

        开启pages步骤如下:

        添加 Android App Links,在这里插入图片描述,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,安装,出现,效果,第11张

        最终出现这个visit site说明成功


文章版权声明:除非注明,否则均为VPS857原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复:表情:
评论列表 (暂无评论,0人围观)

还没有评论,来说两句吧...

目录[+]

取消
微信二维码
微信二维码
支付宝二维码