尽管android:autoVerify ="false",但Android仍尝试验证主机. [英] Android tries to verify host despite android:autoVerify="false"

查看:187
本文介绍了尽管android:autoVerify ="false",但Android仍尝试验证主机.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有3个活动,MainActivity,SecondaryActivity和TertiaryActivity.我希望SecondaryActivity成为Android 6上特定域的默认应用程序链接处理程序,如

我通读了广泛指南应用链接说明了Android上的应用链接处理和应用验证的机制,以下是我在logcat中看到的与应用验证有关的消息:

  03-25 17:54:45.640 1481-1481/com.google.android.gms D/IntentFilterVerificationReceiver:已收到ACTION_INTENT_FILTER_NEEDS_VERIFICATION.03月25日17:54:45.644 1481-30947/com.google.android.gms I/IntentFilterIntentService:正在验证IntentFilter.VerificationId:12方案:"https"主机:"tertiary.com secondary.com"包:"com.antonc.applinktest".03月25日17:54:46.762 1481-30947/com.google.android.gms I/IntentFilterIntentService:验证12完成.成功:错误.失败的主机:tertiary.com,secondary.com. 

您可以看到,即使我在tertiary.com上的意图过滤器中显式设置了android:autoVerify ="false",它仍尝试验证 b secondary.com和tertiary.com!

这是Android的错误吗?如何确保IntentFilterIntentService仅验证我为其设置了android:autoVerify ="true"的意图过滤器,而将另一个过滤器排除在外?

解决方案

这是Android的错误吗?

由于该行为似乎已被记录在案,因此我将其描述为一种限制.引用文档:

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

(添加了重点)

我对此的解释是,如果在应用程序级别上自动验证行为是全有还是全无.对我而言,为什么尚不是这样写的.如果这是一个长期计划,则我希望 autoVerify 属性位于< application> 上.

如何确保IntentFilterIntentService仅验证已为其设置android:autoVerify ="true"的意图过滤器,而将另一个过滤器排除在外?

我想将它们放在单独的应用中.

In my app I have 3 activities, MainActivity, SecondaryActivity and TertiaryActivity. I want SecondaryActivity to be a default app link handler for a particular domain on Android 6, as described in this guide. At the same time, I want another activity, TertiaryActivity, to be able to handle links from another domain, but not be a default handler, as I don't own the domain. Here's my AndroidManifest to illustrate:

<?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>

I read through this extensive guide on app links that explains the mechanics of app link handling and app verification on Android, and here's the messages I see in logcat related to app verification:

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.

As you can see it attempts to verify both secondary.com and tertiary.com, even though I explicitly set android:autoVerify="false" for the intent filter on tertiary.com!

Is this an Android bug? How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?

解决方案

Is this an Android bug?

Since the behavior appears to be documented, I would describe it as a limitation. Quoting the documentation:

When the android:autoVerify attribute is present, installing your app causes the system to attempt to verify all hosts associated with the web URIs in all of your app's intent filters.

(emphasis added)

My interpretation of that is that if auto-verify behavior is all-or-nothing at the app level. It is unclear to me why they wrote it that way. If that is the long-term plan, I would have expected the autoVerify attribute to be on <application>.

How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?

Put them in separate apps, I guess.

这篇关于尽管android:autoVerify ="false",但Android仍尝试验证主机.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆