Test android had to switch screens, press the home button, press the return key triggered lifecycle

Because of the spread of the Internet had to switch screens to question the life cycle of the article, were tested in their own android emulator (Android4.3) and Real (millet m1, android4.0), test results are as follows:


The program is running: the onCreate () -> onStart () -> onResume ()

Press the home button: the onPause () -> the onSaveInstanceState () -> onStop ()

 Then the program icon to enter the trigger: onRestart () ->onStrart()->onResume()

Press the return key: the onPause () -> onStop () -> onDestroy ()

 Then the program icon to enter the trigger: onCreate () -> onStart () -> onResume ()

Start a second Activity: onPause () -> SECOND, the onCreate () -> SECOND, onStart () -> SECOND, onResume ()

-> onSaveInstanceState () -> onStop () (wherein the second means is a second Activity life cycle)

And then return back to the first key Activity: SECOND, onPause () -> onRestart () ->onStrart()->onResume()

->second onStop()->second onDestroy()


Horizontal and vertical screen switching:

1) When the list of documents androidManifest.xml not add Android: configchanges or when adding android: configChanges = "orientation" or add android: configChanges = | when "orientation keyboardHidden", horizontal screen is switched to the vertical screen, vertical screen switch to landscape all It is triggered once:

 onPasue()->onSaveInstanceState()->onStop()->onDestroy()->onCreate()->onStrart()->onRestoreInstanceState()->OnResume()

       2) When the list of documents androidManifest.xml add android: configChanges = "orientation | screenSize " when

Horizontal screen is switched to the vertical screen, vertical screen switch to landscape mode is triggered once : onConfigurationChanged


Reproduced in: https: //www.cnblogs.com/thirstycoder/p/3687154.html

Guess you like

Origin blog.csdn.net/weixin_34150224/article/details/93371084