The life cycle of android--activity and intent and activity

Source: Internet
Author: User

The life cycle of the experimental activity

 Packagecom.example.chenshuai.test;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;/*** Created by Chenshuai on 2016/3/16.*/ Public classAxtivity2extendsActivity {//callback Method@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.layoutactivity); /*System.out.println ("This is the first activity I run"); Output log log.e ("Test", "Log output Information"),//eror Red LOG.W ("test", "Log output Information"),//warning Blue log.d ("test", "Log Input");        Information ");        LOG.I ("Test", "Log output Information"); LOG.V ("Test", "Log output Information");*/LOG.E ("TAG", "create" ); } @Overrideprotected voidOnStart () {Super. OnStart (); LOG.E ("TAG", "Start"); } @Overrideprotected voidOnresume () {Super. Onresume (); LOG.E ("TAG", "Display"); } @Overrideprotected voidOnDestroy () {Super. OnDestroy (); LOG.E ("TAG", "destroy"); } @Overrideprotected voidOnPause () {Super. OnPause (); LOG.E ("TAG", "Pause" ); } @Overrideprotected voidOnStop () {Super. OnStop (); LOG.E ("TAG", "Stop"); } @Overrideprotected voidOnrestart () {Super. Onrestart (); LOG.E ("TAG", "reboot"); }}

When you start an activity

When you click the Home button

Just paused, stopped, not destroyed.

and return

is to restart

When you click the Back button (exit)

Final Destruction

Re-open

will be created again

The life cycle of android--activity and intent and activity

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.