微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

防止 Chrome 吞下 NFC 深层链接

如何解决防止 Chrome 吞下 NFC 深层链接

我设置了一个 Android 测试应用,可以从 NFC 记录的深层链接打开。它有效,但仅当 Chrome 被禁用时。如果 Chrome 没有被禁用,它甚至不会询问,它只会打开 Chrome。

清单:

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

    <uses-permission android:name="android.permission.NFC" />
    <uses-feature android:name="android.hardware.nfc" android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.NDEF_disCOVERED" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.broWSABLE" />
                <data android:scheme="https"
                    android:host="www.example.com"
                    />
            </intent-filter>

            <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:scheme="https"
                    android:host="www.example.com"
                    />
            </intent-filter>
        </activity>
    </application>
</manifest>

如您所见,它同时为 VIEW 和 NDEF_disCOVERED 操作注册。在 VIEW 操作(例如单击来自 Slack 的链接)时,它会询问我是否要打开 Chrome 或我的应用程序。但是,对于 NDEF_disCOVERED 操作,如果 Chrome 没有被禁用,它只会直接打开 Chrome。如果 Chrome 被禁用,他们会询问是否打开我的应用。

我听说这可能与 Android 10 有关,但我不知道是否有我可以请求的权限或可以绕过此行为的内容。我正在运行 Android 10 的 OnePlus 6T 上试用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。