How to use PathPattern in order to create DeepLink Apps Android?

北战南征 提交于 2019-12-01 18:52:43

It's a common drawback in android deep linking that it only support * and . regex character. It's mentioned in Adnroid docs and can be observed in source code.

From docs

For more information on these three types of patterns, see the descriptions of PATTERN_LITERAL, PATTERN_PREFIX, and PATTERN_SIMPLE_GLOB in the PatternMatcher class.

PATTERN_SIMPLE_GLOB is for regex and it says only match

/** * Pattern type: the given pattern is interpreted with a * simple glob syntax for matching against the string it is tested against. * In this syntax, you can use the '*' character to match against zero or * more occurrences of the character immediately before. If the * character before it is '.' it will match any character. The character * '\' can be used as an escape. This essentially provides only the '*' * wildcard part of a normal regexp. */

public static final int PATTERN_SIMPLE_GLOB = 2;

So only *, . and \ is allowed. Usage of other pattern literal +,? etc; will result in failure.

Either you can use your working option or you can use

https://example.com/./....*

....* at least 3 characters then .* mean 0 or more characters

<activity
    android:name="packagename.ActivityName" >
    <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"
              android:host="www.example.com"
              android:pathPattern="/./....*" />
        <!-- note that the leading "/" is required for pathPrefix-->
    </intent-filter>
</activity>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!