App Links[防止被App屏蔽]

Android AppLinks是一种特殊类型的深链接,允许网站URL直接打开已验证的安卓应用内的对应内容,提高用户在链接和应用间切换的体验。配置包括定义intent-filter以使用HTTPURLs打开应用内容,并验证拥有网站和应用所有权。适用场景如ARouter路由跳转,Web端、H5调用原生页面等。实现步骤涉及在AndroidManifest.xml中设置intent-filter,包括scheme和autoVerify属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

What:

谷歌的App Link让用户在点击一个普通web链接的时候可以打开指定app的指定页面,前提是这个app已经安装并且经过了验证,否则会显示一个打开选项的弹出框。自此,在安卓中打开一个链接的用户体验大大提高,用户可以在链接与app之间快速切换。

官方介绍Android App Links内容是:

Android App Links are a special type of deep link that allow your website URLs to immediately open the
corresponding content in your Android app (without requiring the user to select the app).

To add Android App Links to your app, define intent filters that open
your app content using HTTP URLs (as described in [Create Deep Links
to App Content]), and verify that you own both your app and the
website URLs (as described in this guide). If the system successfully
verifies that you own the URLs, the system automatically routes those
URL intents to your app.

Why:

哪些场景可以用到呢?
比如:ARouter 路由 url 跳转的方式;Web端、H5调用原生页面等。

How:

进入正题:
官方给的步骤如下Handling Android App Links

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.infrastructure">

    <application>
        <activity android:name=".router.SchemeFilterActivity">
            <!-- Scheme -->
            <intent-filter>
                <data
                    android:host="m.knowledge.com"
                    android:scheme="arouter"/>

                <action android:name="android.intent.action.VIEW"/>

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

            <!-- App Links -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW"/>

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

                <data
                    android:host="m.knowledge.com"
                    android:scheme="http"/>
                <data
                    android:host="m.knowledge.com"
                    android:scheme="https"/>
            </intent-filter>

        </activity>
        <activity android:name=".router.ARouterTestActivity" />
    </application>

</manifest>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值