Pages Navigation Menu

Coding is much easier than you think

Debugging a service

Debugging a service


You may have written/called a service for your application that may run at the background once it is created. But when you run your application you won€™t be able to see the services when your activity uses the services as it runs at the background and it is not visible. But once the service is completed, it will automatically get closed.  So in this case, it is not possible to debug your service like it is done manually for an activity.


Please follow the steps below in order to debug your service,

Step 1: In the first interesting method of your service (Used in create ()):

/* (non-Javadoc)

* @see



public void onCreate() {


//whatever else you have to to here…

android.os.Debug.waitForDebugger();  // this line is key


Step 2: Set break points after the waitForDebuggerCommand.

Step 3: Launch app via debug button in Eclipse.

Step 4: Now launch adb and run the command to start a service as follows,


adb shell

am startservice -n

About Gokul

I am very much interested in android and Wicket framework. A core android developer and working in android native app development and responsive web mobile design. I have also worked in wicket fame work and java web development. I will keep on updating you about android and wicket framework and answer your query.

%d bloggers like this: