FLAG_ACTIVITY_REORDER_TO_FRONT and startActivityForResult

后端 未结 1 913
半阙折子戏
半阙折子戏 2021-01-13 20:02

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

Now suppose, C makes startActivity c

1条回答
  •  执念已碎
    2021-01-13 20:25

    Judging by the documentation for finish():

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

    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. 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

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

    0 讨论(0)
提交回复
热议问题