How to identify threads using CPU in my Android app

If I run top on my development device, I can see that when my application is using the background of .6% cpu, if I bring it to the foreground it Use 5-6% cpu. The problem is that it is not doing anything. No service is running, no background thread, just waiting for the user to click the button.

Is there a way to do it in adt or through other The tool finds out which thread is eating the cpu so can I know where to start looking for the problem?

Yes, it’s even free. It’s called DDMS, which is an ADT plugin for Eclipse

Connect your device via USB, launch your application, and then open the DDMS view, you will be able to quickly find your CPU-intensive threads.

Please note that it is a good practice to provide human-readable names for the threads generated by the program. Your users will never use these names, but it will make thread debugging/analysis easier:

Thread.currentThread().setName("DB-Access-Thread");

If I run top on my development device As you can see, when my application is in the background that it uses .6% cpu, if I bring it to the foreground it uses 5-6% cpu. The problem is that it is not doing anything. No service is running, There is no background thread, just waiting for the user to click the button.

Is there a way to find out which thread is eating the cpu in adt or through other tools so I can know where to start looking for the problem?

Yes, it is even free. It is called DDMS and is part of Eclipse’s ADT plugin.

Connect your device via USB, launch your application, and then open the DDMS view, you will be able to quickly find your CPU-intensive threads.

Please note that the threads generated by the program are human-readable The names are a good practice. Your users will never use these names, but it will make thread debugging/analysis easier:

Thread.currentThread() .setName("DB-Access-Thread");

Leave a Comment

Your email address will not be published.