Android https 方案的 Intent 过滤器不起作用
Android Intent filter for https scheme not working
我知道这个问题可能与其他一些类似问题重复出现。我已经检查了所有这些,但仍然无法解决这个问题。
我想在点击网页上的 link 时启动我的 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>
浏览器尝试打开(不存在的)页面并忽略 Intent 过滤器。
它不适用于 http、https、ftp 等
我是 运行 Android 6.0 上的应用程序,编译:最小 11,目标 23。
似乎某种机制不允许我使用 "reserved" 方案来启动应用程序,但我在帖子中没有看到任何与此相关的内容。
你知道它是什么吗?
尝试像这样加入两个 data
标签并删除第一个 android.intent.category.DEFAULT
类别,因为它在第一个 intent-filter 根本不需要,但在第二个 intent-filter 是必需的,以便 "the activity should be an option for the default action to perform on a piece of data"
<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>
从 Android Marshmallow 开始,有一个新的 android:autoVerify
标志,您可以使用它来请求 Android 以验证某个域属于您并且您希望链接在您的应用程序而不是浏览器。
"Android 6.0 (API level 23) and higher allow an app to designate
itself as the default handler of a given type of link"
参见:https://developer.android.com/training/app-links/index.html#intent-handler
我知道这个问题可能与其他一些类似问题重复出现。我已经检查了所有这些,但仍然无法解决这个问题。
我想在点击网页上的 link 时启动我的 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>
浏览器尝试打开(不存在的)页面并忽略 Intent 过滤器。 它不适用于 http、https、ftp 等
我是 运行 Android 6.0 上的应用程序,编译:最小 11,目标 23。
似乎某种机制不允许我使用 "reserved" 方案来启动应用程序,但我在帖子中没有看到任何与此相关的内容。
你知道它是什么吗?
尝试像这样加入两个 data
标签并删除第一个 android.intent.category.DEFAULT
类别,因为它在第一个 intent-filter 根本不需要,但在第二个 intent-filter 是必需的,以便 "the activity should be an option for the default action to perform on a piece of data"
<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>
从 Android Marshmallow 开始,有一个新的 android:autoVerify
标志,您可以使用它来请求 Android 以验证某个域属于您并且您希望链接在您的应用程序而不是浏览器。
"Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link"
参见:https://developer.android.com/training/app-links/index.html#intent-handler