添加 Android App Links

添加 Android App Links功能

介绍

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

一个简单的效果

//TODO 添加视频

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

然后效果如下:

Android配置

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

  按照前面三个步骤来。

Add Url intent filters

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

Add logic to handle the intent

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

kotlin 复制代码
// 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

  这步是关键:

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

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

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

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

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

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

开启pages步骤如下:

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

相关推荐
千里马学框架2 天前
一起学 Android 14:ShellTransition 屏幕旋转过程深度剖析
android·智能手机·性能优化·framework·性能·屏幕旋转·rotation
美狐美颜SDK开放平台2 天前
开发直播APP时如何接入视频美颜SDK?开发流程与注意事项
android·人工智能·计算机视觉·音视频·直播美颜sdk
AFinalStone2 天前
Android7 SystemUI源码解析(七)Keyguard锁屏模块深度解析
android·systemui
致远ccc2 天前
Google Play 上架前如何测试 App?多国家 Android 环境测试
android·app测试·googleplay·多国家应用测试
ttyyttemo2 天前
Kotlin 协程中的 Job 结构化并发与取消
android
sun0077002 天前
tbox 4g/5g切换,导致wan ip 改变,导致车机旧网络不可用。需要重启车机才行
android
ai2work2 天前
ch23 综合复刻:从零做一个最小可用版本(capstone)
kotlin
其实防守也摸鱼2 天前
内网穿透与反向代理:原理、工具与实战指南
android·大数据·运维·安全·网络安全·自动化·渗透
ai2work2 天前
ch21 签名、校验与发版
kotlin
AFinalStone2 天前
Android7 SystemUI 源码解析(四)NavigationBar 导航栏与 SystemBars
android·systemui