android deeplinking - 第一个路径前缀是动态的,但第二个不是

Hay*_*yan 2 android manifest deep-linking intentfilter

我有一个网址,例如https://www.mobilePhoneSystem.com/{user}/registerDate/{date}。所以{user}路径前缀是动态的。我只需要处理包含registerDate. 我在清单中写了这样的内容

<!-- Deep linking-->
        <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="https"
                android:host="/www.mobilePhoneSystem.com"
                android:pathPrefix="/registerDate" />

        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

但它不会触发。当我在 mainfest 中添加任何用户时,例如pathPrefix=/user111/registerDate,它会触发并正常工作。但用户是动态的。那么我该如何处理这种类型的深层链接呢?

小智 5

这应该对你有用:

android:pathPattern="/.*/registerDate/.*/"
Run Code Online (Sandbox Code Playgroud)

解释 : 的 . 强制使用“任意字符之一”的模式。.* 强制执行“任意数量(或无!)任意字符”。

将这两者结合起来,..* 强制“任意数量的任意字符,但必须至少提供一个”

  • android:pathPattern="..*/registerDate/..*" - 对于我来说,这个解决方案适用于 2 个点,我没有尝试使用单个点,但无论如何我会接受你的答案。谢谢 (4认同)