DeepLink 与 APPLink 与 IntentFilter跳转

简单总结

  • http协议的跳转,直接 跳转到你的APP (没有任何中间商 赚差价)
    • 中间商就是 一个弹框 QQ浏览器打开、***浏览器打开
    • 只在vivo上如果Manifest的IntentFilter scheme声明 http,不能直接跳转,需要用户在 设置里授权(默认不授权)
    • 那有用户会蛋疼,给app授权 可处理http协议。 这样还不如 自定义其他scheme (怎么解决呢?看下面)
  • 那怎么证明 http://www.your_web.com 绑定的就是你的APP呢?万一跳微信了呢?
    • 用证书,你的http服务器 放一个证书(绑定 包名、URI)
    • APK在安装时,系统会拉取 服务器这个证书,证明 YourApp 对应这个网址
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example",
    "sha256_cert_fingerprints":
    ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
  }
}]

补充20200701

APP Link,http请求 直接跳转应用,没有选择框(用什么浏览器打开)
知乎APP应该就是用的这个,优化了用户体验,web就变成导流了。

  • APP Link (嗯,说的应该是这个)Android App Links are HTTP URLs that bring users directly to specific content in your Android app. 文档

创建步骤

  1. Create intent filters in your manifest.
  2. Add code to your app’s activities to handle incoming links.
  3. Associate your app and your website with Digital Asset Links.

关键

  1. 只能用http、https 的scheme
  2. 必须是Android6.0 和以上手机
  3. 服务器在 https://hostname/.well-known/assetlinks.json上有验证文件,证明APP和url的绑定关系 (具体设置 就不贴了)
  4. 手机会自动拉取验证文件,进行验证。
    在这里插入图片描述

补充下 (之前以为 DeepLink和IntentFilter不同,实际IntentFilter是DeepLink的一种实现方式)

  • 其实都是对 某个资源的描述 URI(统一资源标识符)
  • 无论是资源是 淘宝上的袜子、Android里的Activity、某个地方的一套房子、房子的第几层,都可以通过scheme:://host/path/
    标识

Google对DeepLink的语义解释很宽泛 Google文档,是一种 指向应用链接。
PendIntent通过widget、notification等是explicit deep link,IntentFilter算是implicit deep link

DeepLink 与 IntentFilter跳转

  • DeepLink是指 navigator组件中 用deepLink 为tag的跳转
  • IntentFilter是指 AndroidManifest中用 IntentFilter 为tag的跳转

结论:

采用scheme非http(自定义一个scheme)的IntentFilter跳转更加方便

Scheme 是http的IntentFilter跳转
  • 与 DeepLink 跳转一样效果
  • 与DeepLink跳转一样,需要授权,且默认不授权
    • 也就是默认,你从 http://youhost.com/youapp 跳转不了应用,需要用户授权(太鸡肋了,难不成还要做个引导)
Scheme 不是http的IntentFilter跳转
  • 可以直接跳转,无需授权
  • 不是http 在笔记本等 应用中,不会高亮

配置

DeepLink
  • 需要引入navigation 库

Manifest 文件

//***
    <activity android:name="com.example.android.navigationadvancedsample.MainActivity">
        <nav-graph android:value="@navigation/list" />
    </activity>
    
//***

res/navigation/list.xml

<navigation>
    <fragment
        android:id="@+id/userProfile"
        android:name="com.example.android.navigationadvancedsample.listscreen.UserProfile"
        android:label="@string/title_detail"
        tools:layout="@layout/fragment_user_profile">
        <deepLink
            android:id="@+id/deepLink"
            app:uri="www.example.com/user/{userName}"
            android:autoVerify="true"/>
        <argument
            android:name="userName"
            app:argType="string"/>
    </fragment>
</navigation>

IntentFilter
  • 不需要引入额外的库

Manifest 配置文件

//***
    <activity android:name=".MainActivity2">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="cmo.sogou.translate"
                android:pathPrefix="/test"
                android:scheme="http" />
	    </activity>

//***

测试URI是否有效

adb shell am start
        -W -a android.intent.action.VIEW
        -d "example://gizmos" com.example.android
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值