Android learning-the third day and the third day of android Learning

Source: Internet
Author: User

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.

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