活动堆栈管理
我的活动管理遇到问题。因此,我的活动 A 会转到 B,如果您按 B 中的后退按钮,我希望它转到 A< /strong>,但也有一种情况,B将完成并转到C,如果我按C上的后退按钮,我想要它离开应用程序,基本上返回堆栈是空的。这样做的正确方法是什么?
我能想到的唯一方法就是这样。当 A 启动 B 时,它会在 A 上调用 finish(),而不是在 B 上调用 finish() 我覆盖后退按钮以开始 < strong>A,否则,如果满足某些条件,则在 B 上调用 finish() 并启动 C。必须覆盖后退按钮似乎我做错了什么。
感谢您的帮助。
I am having trouble with my activity management. So I have activity A which goes to B and if you press the back button in B I want it to go to A, but there is also a case where B will finish and go to C and if I press the back button on C I want it to leave the app, basically the back stack is empty. What is the correct way to do this?
The only way I can see to do this is like this. When A starts B it calls finish() on A than on B I override the back button to start A, other wise if certain conditions are met call finish() on B and start C. Having to override the back button seems like I am doing something wrong.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终通过 FLAG_ACTIVITY_CLEAR_TOP 的用户解决了这个问题,这是 nibha 在这篇文章中向我推荐的。 另一篇文章并致电在适当的地方完成()。
I ended up solving this problem through the user of the FLAG_ACTIVITY_CLEAR_TOP which was recommended to me by nibha on this post. Another Post and calling finish() in the appropriate places.