Android的https协议意图过滤器不起作用

3

我知道这个问题可能与其他类似的问题重复。我已经查看了所有这些问题,但仍然无法解决这个问题。

我希望在网页上点击链接时启动我的Android应用程序。当我使用自定义方案时,它可以按预期工作:

<!-- In the deployed webpage: -->
<a href="test://test.com">Launch application </a>

<!-- The Intent filter: -->
<intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="test" android:host="test.com" />
</intent-filter>

但是当将方案更改为“https”时:

<!-- In the deployed webpage: -->
<a href="https://test.com">Launch application </a>

<!-- The Intent filter: -->
<intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="https" android:host="test.com"/>
</intent-filter>

浏览器试图打开(不存在的)页面并忽略意图过滤器。它不适用于http、https、ftp等。

我在Android 6.0上运行应用程序,编译:最低11,目标23。

似乎有些机制不允许我使用“保留”方案来启动应用程序,但我没有在帖子中看到任何相关内容。

你有什么线索吗?

2个回答

2
从Android Marshmallow开始,有一个新的android:autoVerify标志,您可以使用它来请求Android验证某个域名属于您,并且您希望链接在您的应用程序中打开而不是在浏览器中打开。

"Android 6.0(API级别23)及更高版本允许应用程序指定自己为给定类型的链接的默认处理程序"

请参见:https://developer.android.com/training/app-links/index.html#intent-handler

好的,我认为这就是问题的根源。一旦我解决了这个问题,我会立即接受答案。你知道应用链接验证是否适用于自签名的SSL证书吗? - undefined

0
尝试将两个`data`标签连接起来,并删除第一个`android.intent.category.DEFAULT`类别,因为在第一个intent-filter中不需要它,但在第二个intent-filter中是必需的,以便"该活动应该是对数据执行的默认操作的选项"
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="https" android:host="test.com" />
    </intent-filter>
</activity>

你能编辑你的问题并在其中放置有关所讨论活动的完整 XML 吗?请提供来自你的 AndroidManifest.xml 文件中 intent-filter 标签父标签的全部内容。 - undefined
我已按要求编辑了问题。但请记住,这实际上适用于任何自定义模式。只有在使用“http”或“https”时才会失败。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接