Android: Determine Which Code AsyncTask Works

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

Thread <16> AsyncTask # 11

Is there a way to determine which actual section of code is referenced by AsyncTask? Is there something I need to add to the code to define this thread?

+5
source share
1 answer

You can name the stream AsyncTaskat the beginning of your function doInBackground:

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

The specified name will be displayed in the Eclipse debug window, as well as a list of threads in the DDMS perspective.

+12
source

All Articles