Android Development Notes: one-minute explanation of how to use Logcat to debug programs

Source: Internet
Author: User

This is a very simple problem, but every time it is used, it will always be a bit messy. Here we record the steps of Logcat:
1. Declare the tag variable in the Activity (the name is actually casual, as follows:
Private static final String tag = "yan ";
2. When you need to use logcat to output information:
Log. I (tag, "screen width:" + display. getWidth () + "screen height:" + display. getHeight ());
3. Double-click Logcat and click "+ ". Add a new logcat filter, Total ThreeInformation needs to be written. Logcat Filter corresponds to Log. i, by Log Tag corresponds to yan (tag content, corresponds to the above), by Log Level select info (this is the above Log. i, I represents the meaning of info ). As follows:

Then you can debug the program by printing the information! IfLogcatNot Enabled. ClickWindow --- show view ---- other -- android --- Logcat.

Note: If you still cannot see the logcat information after the preceding steps, sometimes it is because verbose Or info in the figure is not selected (that is, it corresponds to verbose in the figure above ).

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.