意图筛选器未按预期工作



我有内部清单,可以在单击链接时启动虚拟活动。

    <intent-filter android:label="Dummy Stuff">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="example.com"
            android:pathPrefix="/services/login/reset.html"
            android:scheme="https" />
    </intent-filter>

当我单击与模式匹配的链接时,它每次都会打开应用程序,但有时它会转到 DummyActivity,有时它会转到它以前在那里的任何活动。知道吗?

另请注意,我正在点击动态链接并使用 Firebase 来处理深层链接。另请注意,即使在显示另一个活动的情况下,我也已使用调试器检查了DummyActivity根本无法打开。因此,我们可以消除DummyActivity将其重定向到另一个的情况。

添加以下内容解决了这个问题:

<data android:pathPattern="/.*" />

因此,意图过滤器如下所示:

<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="example.com" />
            <data android:scheme="https" />
            <data android:pathPattern="/.*" />
</intent-filter>

最新更新