如何返回结果通过多种活动 [英] How to return a result through multiple activities
问题描述
在我的应用程序的某些部分存在着这样的活动的结构:
in some part of my application there is a structure of activities like this:
活动A是我的家活动,我回来的每一个过程和流程之后。
活动B是一个简单的确认的活动。
活动C是另一个确认的活动。
活动ð做了一些处理,最终它回来,结果我家的活动(活动A)。
Activity A is my home activity where I come back after each process or flow.
Activity B is a simple confirmation activity.
Activity C is another confirmation activity.
Activity D does some process and finally it gets back the result to my home activity (Activity A).
b活动ANC C:
- 必须在那里,并且不能在一个合并。
- 在它被点击取消按钮时,它调用完成()和什么也不做。
- 在它被点击确定按钮时,它遵循的流程和当前活动调用完成()
我想使用startActivityForResult(),但我从来没有用它来传递的结果通过多种活动..
我也想传递一个处理器(在活动上创建了),它调用了一些方法对活性方法和活动Ð...
执行
我怎么能实现呢?
I was thinking about using startActivityForResult() but I have never used it to pass a result through multiple activities..
I also was thinking to pass a handler (created in Activity A) which calls some method on Activity A and is executed on Activity D...
How could I implement it?
推荐答案
您可能想利用意图标志的 FLAG_ACTIVITY_FORWARD_RESULT 作为中的意图时开始活动,B和C
You might like to make use of the intent flag FLAG_ACTIVITY_FORWARD_RESULT as described in Intent when starting activities B and C
公共静态最终诠释FLAG_ACTIVITY_FORWARD_RESULT 自:API级别1
public static final int FLAG_ACTIVITY_FORWARD_RESULT Since: API Level 1
如果设置这种意图是被用来从一个现有的启动一个新的活动,则现有的活动的应答目标将被转移到新的活动。通过这种方式,新的活动可以调用的setResult(int)和具有该结果发送回原始活动的应答靶的
这样一个应该拿起在演员发回的所有数据由D-发回
That way A should pick up any data sent back in the extras sent back from D
这篇关于如何返回结果通过多种活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!