且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

打开特定的URL后,将用户从浏览器重定向到我的应用程序

更新时间:2022-11-18 13:31:58

尝试像myapp://returnApp/?status=1一样打开它(添加斜杠字符). 发生这种情况是因为 path 参数定义为默认值/.

Try to open it like myapp://returnApp/?status=1 (add trailing slash character). This is happens because path parameter is defined with default value of /.

不幸的是,您不能完全匹配空字符串.如文档所述:

Unfortunately, you can't match exactly for empty string. As documentation states:

URI的路径部分,必须以/开头.

The path part of a URI which must begin with a /.

如果您确实需要使用完全相同的网址myapp://returnApp?status=1启动应用程序,则可以将android:pathPattern=".*"参数添加到数据子句中,例如

If you are really need to start app with exactly url myapp://returnApp?status=1 you can add android:pathPattern=".*" parameter to your data clause like

<intent-filter>
    ...
    <data android:host="returnApp" android:scheme="myapp" android:pathPattern=".*"></data>
</intent-filter>

数据为android:pathPattern=".*"的意图过滤器将匹配包括空路径在内的任何路径.

Intent filter with data android:pathPattern=".*" will match for any paths including empty one.