如何将活动带到前台(堆栈顶部)? [英] How to bring an activity to foreground (top of stack)?

查看:22
本文介绍了如何将活动带到前台(堆栈顶部)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 中,我定义了一个活动 ExampleActivity.

In Android, I defined an activity ExampleActivity.

当我的应用程序启动时,创建了这个 A-Activity 的一个实例,假设它是 A.当用户单击 A 中的按钮时,B-Activity 的另一个实例 B 被创建.现在任务堆栈是 B-A,B 在顶部.然后,用户点击 B 上的一个按钮,另一个 C-Activity 实例,C 就被创建了.现在任务堆栈是 C-B-A,C 在顶部.

When my application was launched, an instance of this A-Activity was created, say it is A. When user clicked a button in A, another instance of B-Activity, B was created. Now the task stack is B-A, with B at the top. Then, user clicked a button on B, another instance of C-Activity, and C was created. Now the task stack is C-B-A, with C at the top.

现在,当用户单击 C 上的按钮时,我希望应用程序将 A 带到前台,即让 A 位于任务堆栈的顶部,A-C-B.

Now, when user click a button on C, I want the application to bring A to the foreground, i.e. make A to be at the top of task stack, A-C-B.

我该如何编写代码来实现它?

How can I write the code to make it happen?

推荐答案

你可以试试这个 FLAG_ACTIVITY_REORDER_TO_FRONT(该文档准确地描述了您想要的内容)

You can try this FLAG_ACTIVITY_REORDER_TO_FRONT (the document describes exactly what you want to)

这篇关于如何将活动带到前台(堆栈顶部)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆