简体   繁体   English

当app已经运行时,相同的方案url不会打开目标活动

[英]Same scheme url does not open the target activity when app is already running

I am opening my application using scheme url from browser. 我正在使用浏览器中的方案URL打开我的应用程序。 I have an activity say ActivityA that opens up when user clicks a link on a browser and which then starts another activity say ActivityB and finish itself. 我有一个活动说ActivityA会在用户点击浏览器上的链接时打开,然后启动另一个活动,说ActivityB并完成自己。 Now if i have 4 different links with same scheme, all are opening my app properly. 现在,如果我有4个不同的链接具有相同的方案,所有都正在打开我的应用程序。 But when i follow the following procedure 但是,当我按照以下程序

  1. Click on the first link, it opens up the ActivityA which then starts ActivityB. 单击第一个链接,它会打开ActivityA,然后启动ActivityB。
  2. Now the app is running in background. 现在该应用程序正在后台运行。 If I click on second link it also opens up ActivityA. 如果我点击第二个链接,它也会打开ActivityA。 Result is same for third and fourth link. 第三和第四个链接的结果相同。
  3. Now if i again click on the first link while app is running in background, it does not open ActivityA, rather it just brings the app to front. 现在,如果我在应用程序在后台运行时再次单击第一个链接,它不会打开ActivityA,而只是将应用程序放在前面。

您可以在AndroidManifest.xml中设置clearTaskOnLaunch =“true”如果您从应用程序启动浏览器而不是在新任务中启动浏览器(使用FLAG_ACTIVITY_NEW_TASK),并完成当前活动(以完成当前任务)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM