Fragment and parent activity life cycle together

前端 未结 2 1097
盖世英雄少女心
盖世英雄少女心 2020-12-10 07:01

I was following these four topics Creating a Fragment, Handling the Fragment Lifecycle , Managing the Activity Lifecycle and Pausing and Resuming an Activity. So I am in a l

2条回答
  •  执念已碎
    2020-12-10 07:33

    1. If A Activity call B Activity through Intent but A does not call finish() method then A will be in Pause state if B is Transparent or SemiTransparent and in Stop state if B is Opaque. Am I right?

      Yes true

    2. If A Activity contains Fragment F then if A will go to Pause state then F will go to Pause state and if A will be in Stop state then F will be in Stop state too. Am I right?

      Yes correct

    3. If A calls B Activity and B is Transparent then A will be in Pause state and F will too. If B call finish() then A will come to Resume state but what will happen to F? will it come to resume from pause? If it is then how and what steps because I have not seen any direct link in Fragment life cycle which indicates onPause() to onResume() directly as Activity can do.

    What you understood is correct, even in this scenario also fragment will be moved from onPause to onResume state just like an activity. But unfortunately there is not much documentation about this in developer android. This might be because they wanted to avoid complicated diagrams which can create more confusion.

提交回复
热议问题