esm*_*eil 13 payment android intentfilter
我写了一个应用程序,用户点击购买按钮他/她重定向到互联网浏览器(例如:铬)和付款后我想他回到我的应用程序(我的活动),所以我发现我应该使用Intent-Filter但它对我不起作用!
我在清单中添加这些代码:
<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:host="returnApp" android:scheme="myapp"></data>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
当我打开这样的网址时:
MYAPP:// returnApp状态= 1
我的应用程序无法打开.
pep*_*kin 14
尝试打开它myapp://returnApp/?status=1(添加尾部斜杠字符).发生这种情况是因为路径参数定义为默认值/.
不幸的是,你无法完全匹配空字符串.正如文件所述:
URI的路径部分必须以/开头.
如果您确实需要使用完全url启动应用程序,则myapp://returnApp?status=1可以将android:pathPattern=".*"参数添加 到数据子句中
<intent-filter>
...
<data android:host="returnApp" android:scheme="myapp" android:pathPattern=".*"></data>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
具有数据的Intent过滤器android:pathPattern=".*"将匹配任何路径,包括空路径.
<intent-filter android:label="@string/app_name" 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="example.page.link" android:path="/payment"/>
<data android:scheme="http"
android:host="example.page.link" android:path="/payment"/>
</intent-filter>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13791 次 |
| 最近记录: |