Android learning-the third day and the third day of android Learning
Learning Content: Activity lifecycle and LogCat usage
=== Activity lifecycle ====
Figure (reprinted ):
The main function call process is as follows:
OnCreate
OnStart
OnResume
OnPause
OnStop
OnDestroy
If another program with a higher priority needs to be run when the program is running, for example, pressing the Home key, the call is as follows:
OnPause
OnStop
Call the following method to restore an application:
OnStart
OnResume
If the mobile phone supports screen rotation, after rotation, the Activity will be destroyed and the Activity instance will be re-created!
If the main layout file is xxx. xml, then the xxx-land.xml is the default layout file corresponding to the wide screen
Activity can save status information during running. The onSaveInstanceState function can be called within this function.
Save any desired status information to a Bundle object. The onCreate function will provide you with the next running time.
Bundle object, from which you can retrieve the desired status information!
=== Use LogCat ===
LogCat is a component of the IDE tool. It is used to view various log information and easily filter logs and focus on important log information.
IDE does not need to worry about opening LogCat. To view the Log output, the program must record the Log. Android provides the Log class android. util. Log.
Common Log methods:
When using it, you first define a TAG name to indicate the type of the log. LogCat is used to select a specific TAG or filter the TAG keywords. The common method is as follows:
Log. e (...) // error message
Log. w (...) // warning information
Log. I (...) // General information
Log. d (...) // debug information
Log. v (...) // frequently used by developers, and detailed logs are output by developers.