DDMS Perspective

The DDMS Perspective provides a dashboard-like view into the heart of a running Android device, or in our case, a running Android Emulator. Figure 2.5 shows the emulator running the Chapter2 sample application.

We'll walk through the details of the application, including how to build the application and how to start it running in the Android Emulator, but first let's see what we can learn from the DDMS to continue the discussion of the tools available to us for Android development. The Devices view shows a single emulator session, titled emula-tor-tcp-5555. This means that there is a connection to the Android Emulator at TCP/IP port 5555. Within this emulator session, five processes are running. The one of interest to us is com.manning.unlockingandroid, with a process id of 616.

Unless you are testing a peer-to-peer application, you will typically have only a single Android Emulator session running at a time. It is possible to have multiple instances of the Android Emulator running concurrently on a single development machine.

Logging is an essential tool in software development, and that brings us to the LogCat view of the DDMS Perspective. This view provides a glimpse at system and application

Perspective with an application running in the Android Emulator"/>
Figure 2.5 Perspective with an application running in the Android Emulator

logging taking place in the Android Emulator. In figure 2.5, a filter has been set up for looking at entries with a tag of Chapter2. Using a filter on the LogCat is a helpful practice, because it can reduce the noise of all the logging entries and allow us to focus on our own application's entries. In this case, there are four entries in the list matching our filter criteria. We'll look at the source code soon to see how we get our messages into the log. Note that these log entries have a column showing the process id, or PID, of the application contributing the log entry. As expected, the PID for our log entries is 616, matching our running application instance in the emulator.

The File Explorer view is shown in the upper right of figure 2.5. User applications, that is, the ones you and I write, are deployed with a file extension of .apk and are stored in the /data/app directory of the Android device. The File Explorer view also permits filesystem operations such as copying files to and from the Android Emulator as well as removing files from the emulator's filesystem. Figure 2.6 shows the process of deleting a user application from the /data/app directory.

Obviously, being able to casually browse the filesystem of our mobile phone is a great convenience. This is a nice feature to have for mobile development, where we are often relying on cryptic pop-up messages to help us along in the application development and debugging process. With easy access to the filesystem, we can work with files and readily copy them to and from our development computer platform as necessary.

In addition to exploring a running application, the DDMS Perspective provides tools for controlling the emulated environment. For example, the Emulator Control view allows the testing of various connectivity characteristics for both voice and data networks, such as simulating a phone call or receiving an incoming SMS. Figure 2.7 demonstrates sending an SMS message to the Android Emulator.

The DDMS provides quite a bit of visibility into, and control over, the Android Emulator and is a handy tool for evaluating our Android applications. Before we move on to building and testing Android applications, it is helpful to understand what is happening behind the scenes and enabling the functionality of the DDMS.

% Threads g Heap O file Explorer ST

Hj -a ¡ =

1 Si« I Date

Time

Permissions I Info I

Q & data

2007-12-12

17:16

ótwxrwx-x

!±1 & anr

2003-02-25

01:51

drwxrw xrwx

------

B & app

2007-12-12

17:16

<¡rwxmx-x

Cl Apüemos.apk

1325... 2007-12-12 17:15 -rvt-r-r-

thecfcin,db

27648 2003-02-25 04:12 -rw-r--r-

a fe- dalvik-cache

2008-01-19

23:23

drwxmxmx

S & data

2008-01-19

23:23

drwxrwx--x

£) & download

2008-01-19

23:23

drwxrwxr/íx

3 drm

2008-01-19

23:23

drwxrwxrwx

13 l£> logs

2008-01-19

23:23

drwxrwwrwx

a & lost+found

2008*02*25

04:17

<Jrw-rw*rw-

a & rréc

2007-12-12

17:13

<frwxrwww>!

a & system

2008-01-19

23:23

timeione

3 2008-02-25

02:43

-rw-rw-rw-

0 & system

2008-02-12

01:10

drwxr-xi-x

E Ér trrp

2008-02-25

04:17

drwxmxrvA

Figure 2.6 Deleting applications from the emulator by highlighting the application file and clicking the delete button

Figure 2.6 Deleting applications from the emulator by highlighting the application file and clicking the delete button

0 0

Responses

  • LAVINIA
    How to get into ddms perspective?
    9 months ago

Post a comment