Question

(Sorry if I'm butchering any terminology- I'm still getting the hang of Android development. Please feel free to point out my mistakes)

I'm working on a project using several Service objects which appear as separate processes which appear under the Devices window in Eclipse's DDMS perspective. In order to step through one of these, I select its row, and click on the little bug icon (its tooltip is "Debug the selected process, provided its source project is present and open in the workspace").

I'm trying to debug one of these services' instantiation code. That doesn't allow me the needed time to perform those two mouse clicks, so my pre-set breakpoints won't pause the execution where I need.

In desperation I've tried using Thread.sleep() in the Service's onCreate() method, but it's only somewhat helpful, and a nasty habit I'd rather not develop.

What's the right way to debug this sort of code?

Thanks for you help!

Était-ce utile?

La solution

  1. Place a breakpoint at the earliest point possible in the main process (perhaps the first activity or a service that runs at startup).
  2. Right click the breakpoint --> Breakpoint Properties... --> choose 'Suspend VM'
  3. Run your app in debug mode (F11). When it reaches the breakpoint it should halt everything else, giving you the time needed to click the debug icon on the process you want.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top