如何操作Activity返回栈?

发布于 2024-10-03 16:35:45 字数 182 浏览 0 评论 0原文

我想实现以下逻辑。我有 4 个活动 A、B、C 和 D。

流程是 A -> B-> C-> D

当用户从 A -> 导航时C 他应该能够通过按后退按钮返回到之前的活动。但是在到达 D 后,按后退按钮应该将他带到活动 A。再次按后退按钮应该退出应用程序,而不是把他带回到 B/C/D。我该怎么做。

I want to implement the following logic. I have 4 activites A, B, C and D.

The flow is A -> B -> C -> D

When the user navigates from A -> C he should be able to get back to the previous activities by pressing the back button. But after reaching D pressing the back button should take him to activity A. And pressing the back button againg should exit the application instead of taking him back to B / C / D. How do I do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书信已泛黄 2024-10-10 16:35:45

我不知道您是否真的可以像您在标题中建议的那样操作应用程序堆栈。

我的应用程序在 opengl 中运行,所以我实际上从未将一个 Activity 更改为另一个 Activity,但我认为以下原则也适用:

为什么不自己调用您想要的 Activity ?

在后退按钮事件中处理这个问题真的很简单。

背面按下-> 如果您在活动 A 中,则加载您想要的活动

,然后退出

I don't know if you actually can manipulate the stack of application like your suggesting in your title.

My app runs in opengl so I never actually change form one Activity to another but I think the following principle will also work:

Why don't you call the Activity you want yourself ?

it is really straight forwards in the back button event to handle this.

on back pressed -> load activity you want

if your in activity A then exit

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文