我有 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);
关于Android 清除 Activity 之间的返回堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42903367/