我怎样才能做到这在Android中。活动 - > web浏览器 - > Acrivity,但preSS回到看不到web浏览器 [英] How can I do that in Android. Activity -> WebBrowser -> Acrivity, but Press Back not see the WebBrowser

查看:103
本文介绍了我怎样才能做到这在Android中。活动 - > web浏览器 - > Acrivity,但preSS回到看不到web浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何能做到这一点的网络浏览器调用自定义方案启动的活动的话,我想我preSS后退按钮,但不会返回Web浏览器。

How can I do that the web browser call a custom scheme to start a activity, then I want I press the Back Button but not return the web browser.

我只是想实现转发当我打电话web浏览器,然后打电话给我的计划,以启动另一个活动。当我回来了,我不会喜欢看到的网页浏览器。

I just want to implement forwarding when I call a web browser then call my scheme to start another Activity. When I back, I will not like to see the web browser.

我应该怎么办呢?

Intent i = new Intent(Intent.ACTION_VIEW);
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.setData(Uri.parse(url));
startActivity(i);

我已经加入,但它不工作!

I already added it, but it not works!

推荐答案

此可能是因为第二活动发射到从启动浏览器相同的任务,这意味着开始的第二个活动返回到与已经存在的任务最上面的活性(活性1)被推到后端堆栈。请参见这里

This probably happens because the second activity is launched into the same task you started the browser from, which means that starting your second activity returns to the already existing task with the topmost activity (activity 1) pushed to the back-stack. See here.

如果你让你的第二个活动正在启动一个不同的任务,pressing回应该结束了任务,并返回到该任务后,浏览器。

If you make your second activity being started on a different task, pressing "back" should end that task and return to the task behind, the browser.

要实现这个目标,你可以使用 FLAG_ACTIVITY_NEW_TASK 的意图开始活动2,或设置活动的安卓launchMode 属性 singleTop 在你的清单。

To accomplish that, you could use FLAG_ACTIVITY_NEW_TASK in the intent starting activity 2, or set the activity's android:launchMode attribute to singleTop in your manifest.

这篇关于我怎样才能做到这在Android中。活动 - > web浏览器 - > Acrivity,但preSS回到看不到web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆