启动活动和不破坏其他活动 [英] Start Activity and don't destroy other activity

查看:125
本文介绍了启动活动和不破坏其他活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid,开始了活动的一个 - B - C - D.从活动的研发,当我再次打开活性的话,我怎么能启动,以便活动B和C不完成和A再次启动?应该只有一个活动一个。

I am new to Android and started the activities A - B - C - D. From activity D, when I open activity A again then how can I start so that activities B and C don't finish and A starts again? There should only be one activity A.

在此先感谢。

推荐答案

使用了意图国旗 FLAG_ACTIVITY_REORDER_TO_FRONT

在D中

Intent i = new Intent(ActivityD.this, ActivityA.class);
i.setFlags(FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);

这只会带来 ActivityA 到堆栈的前面,留下 B ç他们在哪里我相信这是你想要的。然后,你可以明显地调用完成() D上,如果你想从堆栈中取出。

This will simply bring ActivityA to the front of the stack and leave B and C where they are which I believe is what you want. Then you can obviously call finish() on D if you want to remove it from the stack.

您可以找到意向文档

这篇关于启动活动和不破坏其他活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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