简体   繁体   English

Android如何向片段添加活动

[英]Android how to add activities to backstack like fragments

I have multiple activities. 我有多个活动。 I want to add them to backstack, when i open the activities one by one like fragments. 当我像片段一样逐个打开活动时,我想将它们添加到堆栈中。 Will it be possible for activities to add them in backstack like fragments. 活动是否有可能像片段一样将它们添加到堆栈中。 Any help will be useful. 任何帮助将是有用的。 Thanks! 谢谢!

Just launch new activities on top of an activity and do not finish the current activity. 仅在活动之上启动新活动,而不完成当前活动。 Android will maintain an activity stack of its own. Android将维护自己的活动堆栈。 you will return to the previous activity once you finish the current activity 完成当前活动后,您将返回上一个活动

use this code when you are switching from one activity to another 从一种活动切换到另一种活动时使用此代码

 Intent a = new Intent(this, A.class);
    a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(a);

this will give u 这会给你

A>b>c>d
a>b>c
a>b
a

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

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