Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Identify what code an AsyncTask is running

In Eclipse in the Debug window I see a thread that shows:

Thread <16> AsyncTask #11

Is there a way to determine what actual section of code the AsyncTask is referring to? Is there something I have to add in code to identify that running thread?

like image 810
Johann Avatar asked Sep 28 '11 15:09

Johann


Video Answer


1 Answers

You can name the AsyncTask thread at the beginning of your doInBackground function:

public void doInBackground(Params... params) {
    Thread.currentThread().setName("Foo (AsyncTask)");
    // ... rest of your AsyncTask processing ...
}

The specified name will be shown in the Eclipse Debug window, as well as thread list in DDMS perspective.

like image 188
Xion Avatar answered Nov 09 '22 17:11

Xion