你如何跳过一个活动栈的部分在Android中返回结果的时候? [英] How do you skip parts of an Activity stack when returning results in Android?

查看:151
本文介绍了你如何跳过一个活动栈的部分在Android中返回结果的时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序,它具有流量大致如下:

I'm making an app which has a flow roughly as below:

  1. 在用户开始与空单在主屏幕上,点击菜单,进入添加项目。 (活动A)
  2. 在用户被赋予了新的活动,使它们能够指定搜索条件,然后命中走出去做搜索。 (活动B)
  3. 用户得到的结果列表,并可以点击其中一个查看更多详细信息。 (活动三)
  4. 用户看到项目的详细信息,并可以使用菜单项,将其保存到他们的活动A.列表(活动D)

现在,我有每个活动相互调用活动的结果,然后将它传递结果所有的方式回到堆栈因为它返回到活动A.

Right now, I am having each Activity call each other Activity for results, and then it is passing the result all the way back up the stack as it returns to Activity A.

有没有办法跳这一点,因为我要的是一个结果活动ð去活动的直接可?

Is there a way to jump this, since all I want is for a result in Activity D to get to Activity A directly?

请注意,用户仍然能够通过每个活动向后导航(使用后退按钮),但如果他们明确地保存在活动D中的项目,我希望它直接跳转到活动一个。

Note that a user should still be able to navigate backwards (using the back button) through each activity, but if they explicitly save the item in Activity D, I want it to jump straight to Activity A.

推荐答案

只是使人们可以从我后来才知道受益...

Just so that people can benefit from what I learned later...

的关键解决这个问题是利用使用标志与意图,在这种情况<一href="http://developer.android.com/reference/android/content/Intent.html#FLAG%5FACTIVITY%5FCLEAR%5FTOP"相对=nofollow> FLAG_ACTIVITY_CLEAR_TOP 。其他的标志是有用的,以及在控制你的用户界面的流程。

The key to solving this problem is using flags with Intent, in this case using FLAG_ACTIVITY_CLEAR_TOP. Other flags are useful as well in controlling the flow of your UI.

这是一个坏主意,试图通过活动链接startActivityForResult()来解决这个问题。这意味着,这是很难改变应用程序的流程。

It is a bad idea to try to solve this problem by chaining startActivityForResult() through activities. It means that it's difficult to change the flow of your application.

这篇关于你如何跳过一个活动栈的部分在Android中返回结果的时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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