FLAG_ACTIVITY_REORDER_TO_FRONT和startActivityForResult [英] FLAG_ACTIVITY_REORDER_TO_FRONT and startActivityForResult

查看:183
本文介绍了FLAG_ACTIVITY_REORDER_TO_FRONT和startActivityForResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

活动一开始b使用startActivityForResult,和B开始下使用startActivity。在此之后,活动堆栈A B C

Activity A started B using startActivityForResult, and B started C using startActivity. After that, the activity stack is A B C.

现在假设,C使用FLAG_ACTIVITY_REORDER_TO_FRONT标志使startActivity呼叫B,那么活动的堆栈将成为AC,B。

Now suppose, C makes startActivity call on B using FLAG_ACTIVITY_REORDER_TO_FRONT flag, then the activity stack will become A C B.

我的问题是,目前,在B完成本身,将onActivityResult()的调用由于B的退出?

My question is, now, if B finishes itself, will onActivityResult() in A be called due to B's exiting?

感谢。

推荐答案

评审通过的<一个文档href="http://developer.android.com/reference/android/app/Activity.html#finish%28%29">finish():

打电话当你的活动做   和应关闭。该   ActivityResult传播回   凡经推出,你   onActivityResult()。

Call this when your activity is done and should be closed. The ActivityResult is propagated back to whoever launched you via onActivityResult().

这使我相信,A将获得B的结果,即使C是在两者之间。

This leads me to believe that A will get B's result even if C is in between the two.

修改 - 经过一些测试中,我发现了一些有趣的交互,这里

Edit - after some testing I discovered some interesting interactions here.

事件的顺序,一些日志记录后:

The order of events, after some logging:

  1. 系统启动
  2. 乙开始
  3. 下开始
  4. 乙恢复(带有FLAG_ACTIVITY_BRING_TO_FRONT)
  5. 乙完成
  6. ç恢复(这是在B)
  7. ç完成
  8. 一个简历,并得到B的结果
  1. A started
  2. B started
  3. C started
  4. B resumed (with FLAG_ACTIVITY_BRING_TO_FRONT)
  5. B finished
  6. C resumed (it was under B)
  7. C finished
  8. A resumes and gets B's result

在换句话说,A得到B的结果如预期,但它发生的ç完成后和A重新开始。

In other words, A gets B's result as expected, but it happens after C finishes and A is resumed.

这篇关于FLAG_ACTIVITY_REORDER_TO_FRONT和startActivityForResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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