The first chapter focuses on the Android SDK (4) and androidsdk.

Source: Internet
Author: User

The first chapter focuses on the Android SDK (4) and androidsdk.
1.4 Android debugging-debugging tool (DDMS)

The full name of DDMS is Dalvik Debug Monitor Service, which provides us with many useful services, such as: screenshot capture for devices; view running threads and heap information for specific processes; logcat information, broadcast status information, analog telephone call, SMS reception, virtual geographic coordinates, and so on are one of our very important tools in the development process.

The DDMS tool is stored in the Android-sdk/tools/path. Double-click the ddms tool. bat runs DDMS. If it is in eclipse, Open DDMS through Window-> Open Perspective-> Other-> DDMS.

Figure 1-18 DDMS window

 

How DDMS works:

DDMS sets up the connection between the IDE and our testing terminal (simulator or real machine). They use their independent ports to listen to the information of the debugger. DDMS can monitor the connection of the testing terminal in real time. When a new test terminal connection is available, DDMS captures the terminal ID and establishes a debugger through ADB to send commands to the test terminal.

DDMS is a bridge between IDE and Emultor (or GPhone. Developers can view the running process/thread status on the target machine through DDMS, connect the Eclipse program to the development machine for running, and view the heap information, logcat information, and memory allocated by the process; you can send text messages, send geographic location information, and call messages on the target machine. You can attach a process for debugging like gdb.

DDMS introduction:

1) Device Tab

1-19.

Figure 1-19 Device Tab

 

Device lists all processes in the simulator or real machine. The buttons in the upper-right corner of the tab are: debugging process, updating process, updating process stack information, and stopping a process, the last image button captures the current screen of the Emulator. When you select a process and press the debug process button, if eclipse contains the code of this process, you can perform source code-level debugging. It's a bit like gdb attach. The image capture button can be very useful for the display interface of the current Android device.
2) Threads Tab

Display thread statistics,1-20.

Figure 1-20Threads Tab

 

3) Heap Tab

Display stack information, As shown in figure 1-21.

Figure 1-21Heap Tab

 

Experience Sharing:

The Heap tab plays an important role in optimizing the application memory. The specifics will be carefully described in the following sections.

 

4) File Explorer Tab

Displays the file information, as shown in figure 1-22.

 

Figure 1-22FileExplorer Tab

 

Displays information about the file system on an Android device or simulator. FileExplorer is very useful: it can upload files to Android devices or simulators, download files from devices, or delete files. The upload, download, and delete buttons are available in the upper-right corner of the tab. Generally, File Explorer has the following three directories: data, sdcard, and system.

The RAM of the mobile phone corresponding to data will store temporary data such as Cache during Android OS running (/data/dalvik-cache directory ); if the root permission is not available, the apk program is installed in/data/app (only the apk file itself is stored);/data stores all the programs in Emulator or GPhone (system apk + third-party apk).

Sdcard corresponds to the SD card.

The system corresponds to the ROM, OS, and the apk program of the mobile phone.

The port used by DDMS to listen to the App process on the first terminal is 8600, and the APP process is allocated 8601. If there are more terminals or more APP processes, and so on. DDMS receives commands from all terminals through port 8700 ("base port.

5) Emulator Control tab

Simulation Control tab, as shown in figure 1-23.

Figure 1-23EmulatorControl Tab

 

It can simulate sending text messages, making phone calls, and updating mobile phone location information.

Enter the following content in Emulator Control \ Telephony Actions, as shown in figure 1-24.

Figure 1-24Send SMS messages in simulated Mode

 

Click the Send button to Send a text message to the Android simulator. When the simulator is opened, a text message is displayed, as shown in figure 1-25.

Figure 1-25Receive SMS

 

6) Logcat Tab

You can use the Log class in a program to print information to LogCat. See Figure 1-26.

Figure 1-26Logcat Tab

 

You can click the "+" button in the upper-right corner to add Log Filter to view Log information. For example, you only want to view the "System. out, as shown in the filter1-27.

Figure 1-27Add Log Filter

 

After clicking the "OK" button, a Log Filter is added, which displays all the Log information printed by System. out.


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.