Android尝试验证主机,尽管android:autoVerify ="false"

Ant*_*hyn 6 android intentfilter

在我的应用程序中,我有3个活动,MainActivity,SecondaryActivity和TertiaryActivity.我希望SecondaryActivity成为Android 6上特定域的默认应用程序链接处理程序,如本指南中所述.同时,我希望另一个活动TertiaryActivity能够处理来自另一个域的链接,但不能成为默认处理程序,因为我不拥有该域.这是我的AndroidManifest来说明:

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        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>
        </activity>

        <activity android:name=".SecondaryActivity"
                  android:label="@string/app_name"
                  android:theme="@style/AppTheme.NoActionBar">
            <intent-filter android:autoVerify="true"> <!-- TRUE -->
                <data android:scheme="https"
                      android:host="secondary.com"/>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>

        <activity android:name=".TertiaryActivity"
                  android:label="@string/app_name"
                  android:theme="@style/AppTheme.NoActionBar">
            <intent-filter android:autoVerify="false"> <!-- FALSE -->
                <data android:scheme="https"
                      android:host="tertiary.com"/>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

我阅读了这篇关于应用程序链接的详尽指南,解释了Android上应用程序链接处理和应用程序验证的机制,这里是我在logcat中看到的与应用程序验证相关的消息:

03-25 17:54:45.640 1481-1481/com.google.android.gms D/IntentFilterVerificationReceiver: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.

03-25 17:54:45.644 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verifying IntentFilter. verificationId:12 scheme:"https" hosts:"tertiary.com secondary.com" package:"com.antonc.applinktest".

03-25 17:54:46.762 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verification 12 complete. Success:false. Failed hosts:tertiary.com,secondary.com.
Run Code Online (Sandbox Code Playgroud)

正如你可以看到它试图验证两者 secondary.com和tertiary.com,即使我明确地设置机器人:autoVerify ="假"关于tertiary.com意图过滤器!

这是Android的错误吗?我如何确保IntentFilterIntentService仅验证我已设置android:autoVerify ="true"的intent过滤器并将另一个删除?

Com*_*are 8

这是Android的错误吗?

由于行为似乎有记录,我将其描述为限制.引用文档:

当存在android:autoVerify属性时,安装您的应用程序会导致系统尝试验证与您的所有应用程序的意图过滤器中的Web URI关联的所有主机.

(重点补充)

我对此的解释是,如果自动验证行为在应用程序级别是全有或全无.我不明白为什么他们这样写.如果这是长期计划,我会期望该autoVerify属性开启<application>.

我如何确保IntentFilterIntentService仅验证我已设置android:autoVerify ="true"的intent过滤器并将另一个删除?

我想,把它们放在不同的应用程序中.

  • 这是存在的一种不直观的行为。如果有人找到解决此行为的方法,我会非常感兴趣。 (2认同)