Activity and Fragment Lifecycle, does the onResume fire one after the other?
I

2

6

I am wondering what the proper order goes when a user returns to an Activity from the Home Screen.

Will the Activity's onResume() execute first, and then the Fragment's onResume() execute after? Does it do it in order, or will it do it concurrently?

I put some code in my Fragment's onResume() but it doesn't seem to be firing after the Activity's onResume().

Igal answered 27/2, 2015 at 2:35 Comment(0)
I
8

I am wondering what the proper order goes when a user returns to an Activity from the Home Screen.

Activity's onResume() execute and the Fragment's onResume() execute after. Here is my screen shot of the log:

enter image description here

Will the Activity's onResume() execute first, and then the Fragment's onResume() execute after? Does it do it in order, or will it do it concurrently?

Yes, the two onResume() method execute in order, because they are all executed on the main thread(also called ui thread, it's a single thread), so there is no concurrent problem.

I put some code in my Fragment's onResume() but it doesn't seem to be firing after the Activity's onResume().

I think there is something wrong with your code, you can check it again or post it here, so someone may point your mistake.

Infusion answered 27/2, 2015 at 2:56 Comment(0)
B
3

The fragments onResume() or onPause() will be called only after the Activities onResume() or onPause() is called. They are tightly coupled to the Activity.

Read the Fragment Lifecycle section of this article.

Bannock answered 27/2, 2015 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.