1.4 Android Debug-debug Tool (DDMS)
The full name of DDMS is the Dalvik Debug Monitor service, which provides us with many useful services, such as the ability to take screenshots of a device, view running threads and heap information for a particular process, logcat information, broadcast status information, analog phone calls, receiving SMS , virtual geographical coordinates, etc., is one of the most important tools in our development process.
The DDMS tool is stored under the android-sdk/tools/path and is directly double-clicked Ddms.bat run DDMS, if it is in Eclipse, Window->open perspective->other-> DDMS Open DDMS.
Figure 1-18 Ddms window
How the DDMS works:
DDMS builds the link between the IDE and our test terminal (simulator or real machine), which uses separate ports to listen to the debugger's information, and DDMS can monitor the link of the test terminal in real time. When a new test terminal link is available, the DDMS will capture the ID of the terminal and establish a debugger through ADB to achieve the purpose of sending instructions to the Test terminal.
Ddms is a bridge that bridges the IDE and Emultor (or GPhone). The developer can see the process/thread state running on the target machine through DDMS, can let the Eclipse program connect to the development machine, can see the process's heap information, logcat information, the process allocates the memory situation, can send the message like the target machine, send the geo-location information and call ; You can debug a process like GDB attach.
DDMS Introduction:
1) Device tab
As shown in 1-19.
Figure 1-19 Device tab
The device lists all the processes in the emulator or the real machine, and the top-right corner of the tab is the button: Debug process, update process, update process stack information, stop a process, and the last Picture button is to crawl emulator current screen. When you select a process and press the Debug process button, you can debug at the source level if there is code for the process in eclipse. A bit like gdb attach. The image Grab button can also be useful for displaying the current Android device display screen.
2) Threads tab
Displays the thread statistics, asshown in 1-20.
Figure 1-20 Threads tab
3) Heap Tab
Displays the stack information , as shown in 1-21.
Figure 1-21 Heap tab
|
Experience Sharing:
The Heap tab plays an important role in memory optimization of the application. Specific, will be explained in detail in the following chapters. |
4) File Explorer tab
Displays the file information, as shown in 1-22.
Figure 1-22 fileexplorer tab
Displays file system information on an Android device or emulator. FileExplorer is very useful: it can upload files to an Android device or simulator, or download files from the device, or file delete operations. The top right corner of the tab has three buttons to upload, download, and delete. In general, File Explorer will have the following three directories: Data, SDcard, System.
Data corresponding to the phone's RAM, will be stored in the Android OS runtime cache and other temporary data (/data/dalvik-cache directory), without root privileges when the APK program installed in/data/app (just store the apk file itself);/data/ Data contains detailed directory information for all programs in emulator or Gphone (System apk+ third-party apk).
SDcard corresponds to the SD card.
The system is stored here for the rom,os of the phone and the APK program.
Ddms listens to the first terminal app process port for the 8600,app process will allocate 8601, if there are more terminals or more app processes will follow in this order and so on. The DDMS receives instructions from all terminals via 8700 ports ("Base port").
5) Emulator Control tab
The Analog Control tab, shown in 1-23.
Figure 1-23 emulatorcontrol tab
It can simulate to send text messages to the phone, phone calls, update the location of mobile phone information.
In emulator Control\telephony Actions, enter the following, as shown in 1-24.
Figure 1-24 analog Send SMS
After clicking the Send button, send a text message to the Android emulator, open the simulator, then there is a text message prompt, click Open, 1-25.
Figure 1-25 receiving SMS
6) Logcat tab
can be used in programs, by using the Log class to print information to LogCat. See Figure 1-26for an example.
Figure 1-26 logcat tab
We can filter to see the log information by clicking the "+" button in the upper right corner, for example, if we want to see only the log information for "System.out", we will add a filter1-27 as shown.
Figure 1-27 adding log Filter
When you click the "OK" button, a log Filter is added, which shows all the log messages printed by System.out.
Chapter 工欲善其事 its prerequisite-android SDK tools (4)