简体   繁体   English

在两个活动之间切换而不启动新活动?

[英]Switching Between Two Activities Without Starting New Activity?

Lets say I have a three Activities (Activity A) - (Activity B) - (Activity C) and I am switching between them respectively. 假设我有三个活动(活动A)-(活动B)-(活动C),我分别在这三个活动之间进行切换。 A to B, B to C . A到B,B到C。 What I want to do is after making three passes ( A->B->C ) Back to B from C and then pass again from B to C without starting new Activity. 我想做的是经过三遍(A-> B-> C)从C返回到B,然后再次从B传递到C,而没有启动新的Activity。 I know how to back to Home (C->A) and make a single back (C->B). 我知道如何回到首页(C-> A)并进行单背(C-> B)。 I Hope I made my self clear. 我希望我能说清楚。 Is there a way to make the transition B from C just like using finish() method. 有没有一种方法可以像使用finish()方法那样从C进行转换B。

I suggest you look at the various flags which can be used in an Intent when starting a new Activity . 我建议您在启动新Activity时查看一下可以在Intent使用的各种标志。

One or more of the following may do what you want... 以下一项或多项可能会满足您的要求...

FLAG_ACTIVITY_CLEAR_TOP FLAG_ACTIVITY_CLEAR_TOP

FLAG_ACTIVITY_REORDER_TO_FRONT FLAG_ACTIVITY_REORDER_TO_FRONT

FLAG_ACTIVITY_SINGLE_TOP FLAG_ACTIVITY_SINGLE_TOP

To not create extra instances of an Android activity, the following line to the AndroidManifest.xml inside your activity tag. 要不创建Android活动的额外实例,请在activity标签内的AndroidManifest.xml的以下行。

android:launchMode="singleTop"

Other than “singleTop”, the other ones are “standard”, “singleTop”, and “singleInstance”. 除了“ singleTop”之外,其他的是“标准”,“ singleTop”和“ singleInstance”。 More info here. 更多信息在这里。

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

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