I have read documentation about create an deeplink and use app linking service in android studio 3.0. its pretty simple and easy to understand, but I have little bit problem when my URL has no prefix path. example :
https://example.com//amp
there is no prefix, its directly url pattern.
when i use regex
^[a-z0-9]+(?:-[a-z0-9]+)*$
it doesnt works, error shown as
The URL doesnt map to any activity
when i use only star, like :
https://example.com/*/amp
its show seem error. i got stuck in this step, I've check much tutorial about deeplink, and there always use pathPrefix instead of pathPattern.
please somebody help me. thankyou so much
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>