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

编程入门 行业动态 更新时间:2024-10-28 18:22:30
本文介绍了尽管android:autoVerify ="false",但Android仍尝试验证主机.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

<?xml version ="1.0" encoding ="utf-8"?>< manifest package ="com.antonc.applinktest"xmlns:android ="schemas.android/apk/res/android"><应用android:allowBackup ="true"android:icon ="@ mipmap/ic_launcher"android:label ="@ string/app_name"android:supportsRtl ="true"android:theme ="@ style/AppTheme"><活动android:name =.MainActivity"android:label ="@ string/app_name"android:theme ="@ style/AppTheme.NoActionBar"><意图过滤器>< 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"><!-是--< data android:scheme ="https"android:host ="secondary"/>< 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"><!-假->< data android:scheme ="https"android:host ="tertiary"/>< action android:name ="android.intent.action.VIEW"/>< category android:name ="android.intent.category.DEFAULT"/>< category android:name ="android.intent.category.BROWSABLE"/></intent-filter></activity></应用程序></manifest>

我通读了广泛指南应用链接说明了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 secondary"包:"com.antonc.applinktest".03月25日17:54:46.762 1481-30947/com.google.android.gms I/IntentFilterIntentService:验证12完成.成功:错误.失败的主机:tertiary,secondary.

您可以看到,即使我在tertiary上的意图过滤器中显式设置了android:autoVerify ="false",它仍尝试验证 b secondary和tertiary!这是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="schemas.android/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"/> <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"/> <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 secondary" 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,secondary.

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

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仍尝试验证主机.

本文发布于:2023-10-29 17:11:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540284.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机   autoVerify   android   quot   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!