如何管理活动栈? [英] How to manage activity stack?

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

问题描述

在我的筹码是在这种情况下:

When my stack is in this situation:

A->B->C

如果我开始开发活动,我想该活动栈变成:

if I start D activity, I want that the activity stack becomes:

A->D

请注意该活动C是一个对话框。

Note that activity C is a dialog.

推荐答案

下面是它会做的步骤所需要的:

here are the steps which will do the needed:

  • 从活动Ç推出的活动时,用布尔 fromActivityC 捆绑的意向和标志 FLAG_ACTIVITY_CLEAR_TOP 设置。
  • 现在,在活动的上创建检查这个布尔fromActivityC第一,如果present启动活动Ð其他正常的流程继续。

  • from activity C launch the activity A with a boolean fromActivityC bundled with the intent and the flag FLAG_ACTIVITY_CLEAR_TOP set .
  • Now in the on create of the activity A check for this boolean "fromActivityC" first and if present launch the activity D else the normal flow continues.

// following code can be used to get the boolean in the oncreate
boolean entrypoint=this.getIntent().getExtras().getBoolean("fromActivityC");

有一个可爱的小的解决方法,但希望它可以帮助

A lil workaround but Hope it helps

这篇关于如何管理活动栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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