我想为这两个http网址
创建深层链接https://sample-app-123.appspot.com/backoffice/#/user_reset_password?email=abc@gmail.com https://sample-app-123.appspot.com/backoffice/#/user_create_password?email=abc@gmail.com
我已经完成了各种StackOverflow答案,但都没有奏效。我知道Android使用 PatternMatcher.PATTERN_SIMPLE_GLOB 来匹配模式而不是正则表达式。
我的清单看起来像
<activity android:name=".CreateActivity"
android:label="Create Password"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.VIEW"/>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data
android:host="sample-app-123.appspot.com"
android:scheme="https"
android:pathPattern=".*create_password.*"
/>
</intent-filter>
</activity>
<activity android:name=".ResetActivity"
android:label="Reset Password"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.VIEW"/>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data
android:host="sample-app-123.appspot.com"
android:scheme="https"
android:pathPattern=".*reset_password.*"
/>
</intent-filter>
</activity>
我已经创建了几个用于检查 PatternMatcher.PATTERN_SIMPLE_GLOB 的测试,所有测试都已通过,我无法解释为什么它无法正常工作
public void testPatternMatcher() throws Exception {
PatternMatcher mPatternMatcher;
mPatternMatcher = new PatternMatcher("https://sample-app-123.appspot.com/backoffice\\/#\\/user_create_password.*", PatternMatcher.PATTERN_SIMPLE_GLOB);
assertTrue(mPatternMatcher.match("https://sample-app-123.appspot.com/backoffice/#/user_create_password?email=abc@gmail.com"));
assertFalse(mPatternMatcher.match("https://sample-app-123.appspot.com/backoffice/#/user_reset_password?email=abc@gmail.com"));
mPatternMatcher = new PatternMatcher(".*user_create_password.*", PatternMatcher.PATTERN_SIMPLE_GLOB);
assertTrue(mPatternMatcher.match("https://sample-app-123.appspot.com/backoffice/#/user_create_password?email=abc@gmail.com"));
assertFalse(mPatternMatcher.match("https://sample-app-123.appspot.com/backoffice/#/user_reset_password?email=abc@gmail.com"));
mPatternMatcher = new PatternMatcher(".*user_reset_password.*", PatternMatcher.PATTERN_SIMPLE_GLOB);
assertFalse(mPatternMatcher.match("/backoffice/#/user_create_password?email=abc@gmail.com"));
assertTrue(mPatternMatcher.match("/backoffice/#/user_reset_password?email=abc@gmail.com"));
}
答案 0 :(得分:2)
create_password
或reset_password
不属于uri路径的一部分
uri路径在#
字符之前结束。这是一个特殊字符,用于从query
(或锚点)界定hash
。
https://
sample-app-123.appspot.com
/backoffice/
#/user_reset_password?email=abc@gmail.com
您应该使用以下网址:
https://sample-app-123.appspot.com/backoffice/user_reset_password?email=abc@gmail.com
https://sample-app-123.appspot.com/backoffice/user_create_password?email=abc@gmail.com
这将按预期工作。
方案:https://
sample-app-123.appspot.com
/backoffice/user_create_password
email=abc@gmail.com