Fragment life cycle

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/forever_crying/article/details/8238863

I. Life cycle of the fragment

Two. Comparison with the activity life cycle

Scenario Demo: Switch to the fragment

11-29 14:26:35.095:d/applistfragment (7649): Onattach
11-29 14:26:35.095:d/applistfragment (7649): onCreate
11-29 14:26:35.095:d/applistfragment (7649): Oncreateview
11-29 14:26:35.100:d/applistfragment (7649): onactivitycreated
11-29 14:26:35.120:d/applistfragment (7649): OnStart
11-29 14:26:35.120:d/applistfragment (7649): Onresume

Screen off:

11-29 14:27:35.185:d/applistfragment (7649): OnPause
11-29 14:27:35.205:d/applistfragment (7649): onsaveinstancestate
11-29 14:27:35.205:d/applistfragment (7649): OnStop

Screen unlock

11-29 14:33:13.240:d/applistfragment (7649): OnStart
11-29 14:33:13.275:d/applistfragment (7649): Onresume

To switch to another fragment:
11-29 14:33:33.655:d/applistfragment (7649): OnPause
11-29 14:33:33.655:d/applistfragment (7649): OnStop
11-29 14:33:33.660:d/applistfragment (7649): Ondestroyview

Switch back to the fragment itself:

11-29 14:33:55.820:d/applistfragment (7649): Oncreateview
11-29 14:33:55.825:d/applistfragment (7649): onactivitycreated
11-29 14:33:55.825:d/applistfragment (7649): OnStart
11-29 14:33:55.825:d/applistfragment (7649): Onresume

Back to Desktop

11-29 14:34:26.590:d/applistfragment (7649): OnPause
11-29 14:34:26.880:d/applistfragment (7649): onsaveinstancestate
11-29 14:34:26.880:d/applistfragment (7649): OnStop

Back to Application

11-29 14:36:51.940:d/applistfragment (7649): OnStart
11-29 14:36:51.940:d/applistfragment (7649): Onresume

Exit the App

11-29 14:37:03.020:d/applistfragment (7649): OnPause
11-29 14:37:03.155:d/applistfragment (7649): OnStop
11-29 14:37:03.155:d/applistfragment (7649): Ondestroyview
11-29 14:37:03.165:d/applistfragment (7649): OnDestroy
11-29 14:37:03.165:d/applistfragment (7649): Ondetach

Fragment life cycle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.