Activity Life cycle Execution Results

Source: Internet
Author: User

Enter testnotificaitonactivity

01-16 16:17:12.172:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:47:oncreate]-TestNotificaitonA ctivity >> = = OnCreate
01-16 16:17:12.172:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:55:setcontentview]-TestNotific aitonactivity >> = = Setcontentview
01-16 16:17:12.202:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:73:onstart]-TestNotificaitonAc tivity >> = = OnStart
01-16 16:17:12.202:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:81:onresume]-TestNotificaitonA ctivity >> = = Onresume

From Testnotificaitonactivity to other acitivity, the end of the testnotificaitonactivity cycle.

01-16 16:18:20.088:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:89:onpause]-TestNotificaitonAc tivity >> = = OnPause
01-16 16:18:20.508:d/testnotificaitonactivity (26710): Hdolc [1:baseactivity.java:97:onstop]-TestNotificaitonAct ivity >> = = OnStop

Testnotificaitonactivity return keys to other places. End period of testnotificaitonactivity

01-16 16:56:16.659:d/demoactivity (31520): Hdolc [1:baseactivity.java:113:finish]-demoactivity >> = = Finis H
01-16 16:56:16.669:d/demoactivity (31520): Hdolc [1:baseactivity.java:89:onpause]-demoactivity >> = = OnPau Se
01-16 16:56:17.019:d/demoactivity (31520): Hdolc [1:baseactivity.java:97:onstop]-demoactivity >> = = OnStop
01-16 16:56:17.029:d/demoactivity (31520): Hdolc [1:baseactivity.java:105:ondestroy]-DemoActivity >> = = On Destroy

If you click Execute Finish ()

01-16 17:01:15.060:d/demoactivity (32264): Hdolc [1:demoactivity.java:221:clickfinish]-DemoActivity >> CLI Ckfinish
01-16 17:01:15.070:d/demoactivity (32264): Hdolc [1:baseactivity.java:113:finish]-demoactivity >> = = Finis H
01-16 17:01:15.110:d/demoactivity (32264): Hdolc [1:baseactivity.java:89:onpause]-demoactivity >> = = OnPau Se
01-16 17:01:15.461:d/demoactivity (32264): Hdolc [1:baseactivity.java:97:onstop]-demoactivity >> = = OnStop
01-16 17:01:15.491:d/demoactivity (32264): Hdolc [1:baseactivity.java:105:ondestroy]-DemoActivity >> = = On Destroy

The OnDestroy method is executed when the "return key" or "finish" is pressed in summary.

Finishi is the end of the activity's life cycle, called the Destory method

Activity.finish ()
Call the When the your activity is do and should be closed.
Call this method when your activity is completed, or when the activity needs to be closed.
When you call this method, the system simply moves the top activity out of the stack and does not call the Ondestory () method in a timely manner, and its resources are not released in a timely manner. Because the stack is removed, you won't find the activity when you click on the "Back" button on your phone.
Activity.ondestory ()
The system is temporarily destroying this instance of the activity to save space.
The system destroys the space occupied by the instance of the activity in memory.
During the activity life cycle, the Ondestory () method is the last step of his life, and the resource space is recycled. When you re-enter this activity, you must recreate and execute the OnCreate () method.

Set activity never expires, i.e. do not execute OnDestroy ()

/***/@Overridepublicvoid  finish ()    {//  // Remember not to perform this sentence    movetasktoback (true// Set the activity never expires , that is, do not execute OnDestroy ()}   

Note: Do not call Super.finish (), Just call Movetasktoback (true) to do so, so that only OnCreate () will be executed at the first boot time. Will not execute after (as long as the process does not die) OnCreate ()

Activity Life cycle Execution Results

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.