Android Intent Filter无法跳转,如何修改Manifest实现重定向?
解决Android Intent Filter无法匹配带路径URL的问题
你的Intent Filter当前仅匹配facix.fr的根域名,而重定向目标URL包含路径/success,因此无法触发应用启动。只需在<data>标签中添加路径匹配规则即可解决。
修改后的Manifest配置
<intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter android:autoVerify="true"> <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="facix.fr" android:pathPattern=".*" /> <!-- 匹配该域名下任意路径 --> </intent-filter> <intent-filter android:autoVerify="true"> <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="facix.fr" android:pathPattern=".*" /> <!-- 匹配该域名下任意路径 --> </intent-filter>
可选的精确匹配规则
如果仅需匹配/success这一特定路径,可将android:pathPattern=".*"替换为:
android:path="/success"
额外说明
- 若保留
android:autoVerify="true",需确保网站服务器的.well-known/assetlinks.json文件配置正确,否则App Links验证失败会导致Intent Filter无法正常触发。 pathPattern支持通配符:.*匹配任意字符序列,*匹配任意长度的单个字符,如需更复杂的路径匹配可参考官方规则。
内容的提问来源于stack exchange,提问作者Thomas KOEBEL
相关产品推荐
相关产品推荐

