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.
650) this.width=650; "Src=" http://img.blog.csdn.net/20141023105915671?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvym9va3poyw9waw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "/>
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!
650) this.width=650; "Src=" http://img.blog.csdn.net/20141023110212434?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvym9va3poyw9waw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" font-family:arial, Helvetica, Sans-serif;font-size:12px;white-space:normal;background-color:rgb ( 255,255,255); "/>
PhoneGap, "Building cross-platform App:phonegap mobile application Practice" serial Two (life cycle)