Using debugging helper classes
Android provides debug helper classes such as util.Log and Debug for your convenience.
Configuring Your IDE to Attach to the Debugging Port
DDMS will assign a specific debugging port to every virtual machine that it
finds on the emulator. You must either attach your IDE to that
port (listed on the Info tab for that VM), or you can use a default port 8700
to connect to whatever application is currently selected on the list of discovered
virtual machines.
Your IDE should attach to your application running on the emulator, showing you
its threads and allowing you to suspend them, inspect their state, and set breakpoints.
If you selected "Wait for debugger" in the Development settings panel
the application will run when Eclipse connects, so you will need to set any breakpoints
you want before connecting.
Changing either the application being debugged or the "Wait for debugger"
option causes the system to kill the selected application if it is currently
running. You can use this to kill your application if it is in a bad state
by simply going to the settings and toggling the checkbox.