Android DeepLink原理与应用(2)

本文探讨了Android框架如何实现DeepLink,主要关注Intent跳转。通过分析IntentFilter和Intent.CATEGORY_BROWSABLE的处理,揭示了从Uri识别到Activity启动的流程,涉及PackageManagerService、IntentResolver和ActivityStackSupervisor等关键组件。
摘要由CSDN通过智能技术生成

上一篇提到Android使用DeepLink跳转有两种方式:Intent跳转、WebView网页跳转。这篇研究一下Android框架如何实现DeepLink。以下Android源代码分析版本为Android7.1。
(1)Intent跳转
这其实是一个Intent filter + start Activity的过程,使用的Intent Catagory是Intent.CATEGORY_BROWSABLE,从这入手。先在Android框架层代码中搜索一下看看哪些地方处理了Intent.CATEGORY_BROWSABLE?发现在处理Intent过滤的工具类中有处理:
frameworks/base/core/java/android/content/IntentFilter.java:

    /**
     * Return if this filter handles HTTP or HTTPS data URIs.
     *
     * @return True if the filter handles ACTION_VIEW/CATEGORY_BROWSABLE,
     * has at least one HTTP or HTTPS data URI pattern defined, and optionally
     * does not define any non-http/https data URI patterns.
     *
     * This will check if if the Intent action is {@link android.content.Intent#ACTION_VIEW} and
     * the Intent category is {@link android.content.Intent#CATEGORY_BROWSABLE} and the Intent
     * data scheme is "http" or "https".
     *
     * @param onlyWebSchemes When true, requires that the intent filter declare
     *     that it handles *only* http: or https: schemes.  This is a requirement for
     *     the intent filter's domain linkage being verifiable.
     * @hide
     */
    public final boolean handlesWebUris(boolean onlyWebSchemes) {
        // Require ACTION_VIEW, CATEGORY_BROWSEABLE, and at least one scheme
        if (!hasAction(Intent.ACTION_VIEW)
            || !hasCategory(Intent.CATEGORY_BROWSABLE)
            || mDataSchemes == null
            || mDataSchemes.size() == 0) {
            return false;
        }

        // Now allow only the schemes "http" and "https"
        final int N = mDataSchemes.size();
        for (int</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值