Android 清除 Activity 之间的返回堆栈

标签 android android-activity stack

我有 4 个 Activity : Activity A -> Activity B -> Activity C -> Activity D 我想要实现的是从 D 回到 A 并清除 B 和 C。这可能吗?怎么办??

非常感谢。

最佳答案

If the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

Intent intent = new Intent(this, ActivityA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

Read more here.

关于Android 清除 Activity 之间的返回堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42903367/

相关文章:

Android 4.3+, android :textColorHint doesn't work, 提示颜色始终为白色

android - 如何在一个应用程序之间向android中的另一个应用程序发送数据?

Android - 重启后打开系列 Activity

c++ - 将单个字符串分成多个堆栈

java - 如何在RelativeLayout中固定Textview的位置

java - Android Marshmallow 上的内容提供商结果中缺少短信

在 Prolog : Not enough memory 中对大列表进行排序

java - 迷宫求解器问题(出现堆栈溢出错误)

java - 如果不执行位置

android - finish() 在第一次运行后调用时不关闭 Activity