在Android的后台堆栈中返回不同的Activity [英] Go back to different Activity in back stack in Android
问题描述
假设我有一个这样的活动堆栈:A -> B -> C -> D
Say I have an activity stack as such: A -> B -> C -> D
我想创建一个新的活动E",最终得到一个这样的堆栈:A -> B -> E
I would like to create a new activity "E", and end up with a stack like this: A -> B -> E
基本上,在活动 D 中点击返回按钮后,我需要将活动 C 换成活动 E,然后登陆它.
Basically, upon hitting the back button in activity D, I need to swap out activity C for activity E, and land on it.
这可能吗?还是我应该以不同的方式构建导航?谢谢!
Is this possible? Or should I be structuring the navigation differently somehow? Thanks!
推荐答案
so while 从活动 C 到 D finish();
C 活动.
so while going from activity C to D finish();
C activity.
最后在ActivityD的backPress方法调用activityE和finish();
ActivityD
At last at backPress method of Activity D call activity E and finish();
Activity D
这篇关于在Android的后台堆栈中返回不同的Activity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!