Home > Articles > Programming > C/C++

  • Print
  • + Share This
This chapter is from the book

Debugging Applications with DDMS

The Dalvik Debug Monitor Service (DDMS) is a debugging utility that is integrated into Eclipse through the DDMS perspective. The DDMS perspective provides a number of useful features for interacting with emulators and handsets (see Figure 2.2).

Figure 2.2

Figure 2.2 The DDMS perspective, with one emulator and one Android device connected.

The features of DDMS are roughly divided into five functional areas:

  • Task management
  • File management
  • Emulator interaction
  • Logging
  • Screen captures

DDMS and the DDMS perspective are essential debugging tools. Now let's take a look at how to use these features in a bit more detail.

Managing Tasks

The top-left corner of the DDMS lists the emulators and handsets currently connected. You can select individual instances and inspect processes and threads. You can inspect threads by clicking on the device process you are interested in—for example, com.androidbook.droid1—and clicking the Update Threads button (02fig02a.jpg), as shown in Figure 2.3. You can also prompt garbage collection on a process and then view the heap updates by clicking the green cylinder button (02fig02b.jpg). Finally, you can stop a process by clicking the button that resembles a stop sign (02fig02c.jpg).

Figure 2.3

Figure 2.3 Using DDMS to examine thread activity for the Droid1 application.

Browsing the Android File System

You can use the DDMS File Explorer to browse files and directories on the emulator or a device (see Figure 2.4). You can copy files between the Android file system and your development machine by using the push (02fig03b.jpg) and pull (02fig03c.jpg) icons.

Figure 2.4

Figure 2.4 Using the DDMS File Explorer to browse system fonts on the handset.

You can also delete files and directories by using the minus button (02fig04a.jpg) or just pressing Delete. There is no confirmation for this Delete operation, nor can it be undone.

Interacting with Emulators

DDMS can send a number of events, such as simulated calls, SMS messages, and location coordinates, to specific emulator instances. These features are found under the Emulator Control tab in DDMS. These events are all "one way," meaning that they can be initiated from DDMS, not from the emulator to DDMS.

Simulating Incoming Calls to the Emulator

You can simulate incoming voice calls by using the DDMS Emulator Control tab (see Figure 2.5). This is not a real call; no data (voice or otherwise) is transmitted between the caller and the receiver.

Figure 2.5

Figure 2.5 Using the DDMS Emulator Control tab (left) to place a call to the emulator (right).

Simulating Incoming SMS Messages to the Emulator

You can simulate incoming SMS messages by using the DDMS Emulator DDMS (see Figure 2.6). You send an SMS much as you initiate a voice call.

Figure 2.6

Figure 2.6 Using the DDMS Emulator Control tab (left) to send an SMS message to the emulator (right).

Taking Screenshots of the Emulator or Handset

One feature that can be particularly useful for debugging both handsets and emulators is the ability to take screenshots of the current screen (see Figure 2.7).

Figure 2.7

Figure 2.7 Using the DDMS Screen Capture button to take a screenshot of the handset.

Viewing Log Information

The LogCat logging utility that is integrated into DDMS allows you to view the Android logging console. You may have noted the LogCat logging tab, with its diagnostic output, in many of the figures shown so far in this chapter. We will talk more about how to implement your own custom application logging in Hour 3, "Building Android Applications."

  • + Share This
  • 🔖 Save To Your Account