4. Introduction to Android Life cycle

Source: Internet
Author: User

1. What activity

is an interactive interface that fills the window or hovers over other windows, and an application consists of multiple activity, which specifies a master activity in the Mainifest.xml.

When the program runs for the first time, it sees the main activity, which is related to the activity by initiating other activity.

When other activity is started, the current activity will stop, new activity is pressed into the stack, colleagues get the user focus

Because the stack is advanced after the user back, the current page is destroyed, before the page is displayed

2. Life cycle of activity

7 Methods 3 stages:

void OnCreate (Bundle savedinstancestate)

void OnStart ()

void Onrestart ()

void Onresume ()

void OnPause ()

void OnStop ()

void OnDestroy ()

  

Start Activity:oncreate, OnStart, Onresume

Activity regain focus: Onrestart, OnStart, Onresume

Close Activity:onpause, OnStop, ondestory

  

The specific life cycle of the activity is as follows:

Overall life cycle: Oncreate->...->ondestory

Visual life cycle: Onstart->...->onstop

Focus Life cycle: Onresume->...->onpause

4. Introduction to Android 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.