![]() ![]() I expect 1-2, but i expect that Fragment call onStart, because, if i understand it correct, onStart called when fragment become visible. I remember, they both have Stopped status (because of onStop was called). Like situation 2, Activity with Fragment are back to the foreground. I thought Fragment should be the first who called stop methods, like (Fragment onPause -> Fragment onStop - > Activity methods). ![]() When i run it, i expect another behavior. Like situation 1, but now Fragment and Activity loaded and i pressed Home: But what is 8? When i load Fragment(since 3), Activity is never on foreground. ![]() Ok, i can understand: 9 is about Fragment came to the foreground, take focus and onResume was called. Threads that are attached to an activity/fragment: These threads are tied to the lifecycle of the activity/fragment and are terminated as soon as the. ![]() In Android, when using fragments, there are two alternative fragment implementations you can use. As part of a FragmentTransaction, you can set a maximum lifecycle state on a fragment using setMaxLifecycle (). But it has extra events that are particular to the fragment’s view hierarchy, state and attachment to its activity. It seems like some kind of "switch focus" between Fragment and Activity. As you can see, the fragment’s lifecycle intertwines with the activity’s lifecycle. You can keep a record of these changes in a back stack that is managed by the activity, allowing the changes to be reversed. While your activity is in the STARTED lifecycle state or higher, fragments can be added, replaced, or removed. When app started, Fragment become active and user see only Fragment.ġ) There is no onResume between 2 - 3, because of Activity lose focus?Ģ) I don't think i understand what happen on 8 - 9. Dividing your UI into fragments makes it easier to modify your activity's appearance at runtime. One launcher Activity with one Fragment, which filled it. I need you help to understand some points. I trace lifecycle method's callback from Activity and Fragment components and i have a lot of questions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |