Android 仅匹配域的意图筛选器(无路径)

Android 仅匹配域的意图筛选器(无路径),android,android-manifest,intentfilter,Android,Android Manifest,Intentfilter,这看起来很简单,但我还不知道怎么做 我需要我的应用程序打开时,用户点击域url。 我需要将URL与没有路径的域(android:host)匹配。 example.com或example.com/ 我让它在example.com/(使用斜杠)上工作,但是没有斜杠我无法捕获URL:example.com 我尝试使用pathPattern/*,但它也不起作用 以下是我的Android清单: <intent-filter> <action android:name="andro

这看起来很简单,但我还不知道怎么做

我需要我的应用程序打开时,用户点击域url。 我需要将URL与没有路径的域(android:host)匹配。 example.com或example.com/

我让它在example.com/(使用斜杠)上工作,但是没有斜杠我无法捕获URL:example.com

我尝试使用pathPattern/*,但它也不起作用

以下是我的Android清单:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" />
    <data android:scheme="https" />

    <data android:host="example.com" />
    <data android:host="www.example.com" />

    <data android:pathPattern="/*" />
    <data android:path="/" />
</intent-filter>


您不需要多个数据标签,在这种情况下只需要一个。每个数据标记可以有一个方案、主机、路径、路径模式等。如果没有方案,则忽略其余方案。如果没有主机(只有方案),则忽略路径属性。做你想做的事的正确方法是


这就是你所需要的

Android Studio的URL映射编辑器对我来说是个误导。它说这将映射到具有以下配置的MainActivity,但实际上并非如此。仅映射到MainActivity

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="www.example.org"
        android:path="/"
        android:scheme="https" />
</intent-filter>

这不起作用。没有路径参数,只有
http://example.com/
匹配,而不是
http://example.com
(通过adb外壳启动测试)