PhoneGap, "Building cross-platform App:phonegap mobile application Practice" serial Two (life cycle)

Source: Internet
Author: User

4.1 What is life cycle

To truly understand the connotation of phonegap application development, you first need to understand what life cycle is. This is literally very easy to understand, and the process of an app being loaded from the beginning of the run to the app being exited is called a life cycle. To make it easier for readers to understand, this section combines the life cycle of activity classes in the Android native SDK with the Logcat debugging tools in Eclipse.

The life cycle of the 4.1.1 activity

Take a closer look at Figure 4-1, which is Google's official activity Lifecycle flowchart, which includes events from the time the Android app was created to the end. The following are the processes that are experienced in the activity life cycle.

(1) Start activity: The system will call the OnCreate method to create a new activity object, and then call the OnStart method and the Onresume method to get the activity you just created into the running state.

(2) Suspend state: The current activity is covered by other activity or mobile phone lock screen, the original activity is put into the background, the system will call the OnPause method to put the activity into a paused state.

(3) Recovery state: When activity in the paused state is re-run, the system calls the Onresume method to return to the running state.

(4) Background status: When the user clicks the Home button to return to the main screen, activity is saved in the background, the system will call the OnPause method and then call the OnStop method to put the activity in a paused state.

(5) Return status: When the user re-opens the activity, the system calls the Onrestar method before calling the OnStar method, and finally calls the Onresume method to return the app to the running state.

(6) The current activity is in a covered state or the background is not visible, that is, the 2nd and 4th steps, the system memory is not enough, kill the current activity, and then the user returned to the current activity: Call OnCreate method Again, OnStart method, Onresume method, enter the running state.

(7) The user exits the current activity: The system calls the OnPause method first, then calls the OnStop method, and finally calls the Ondestory method to end the current activity.

Figure 4-1 Life cycle of activity

After some explanation, I believe the reader can already understand the contents of figure 4-1, but why do you do so?

As we all know, the intelligent machine relative to the non-smart phone is an important feature is that the smart machine has "backstage", can run multiple programs at the same time. For example, you can hang QQ while listening to music while browsing the content of Weibo, and if someone calls in, the phone can automatically switch the interface of the call, and all this is through the life cycle to achieve.

Tsinghua University Press launched the "build cross-platform App:phonegap mobile app" is an app book, contains more than 20 app instances and 3 app projects, but also combined with HTML5 mobile development. This book is for mobile development beginners, low threshold, shallow reading, the most suitable for mobile app startup small white. This release of the 3rd to 5th chapter as the basis for readers to learn, interested in the Welcome to buy this book! Welcome Dabigatran: 348632872, direct questions to the author to communicate!

PhoneGap, "Building cross-platform App:phonegap mobile application Practice" serial Two (life cycle)

Related Article

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: 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.