O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a simple AsyncTask

Let's get into the details now. We will show you the following through source code:

  • How to extend AsyncTask
  • How to pass constructor arguments
  • What methods to override
  • How to set up a progress dialog through the preexecute() method
  • Where to do the actual work: the doInBackground() method
  • How to trigger progress callbacks
  • How to override the progress method to report progress
  • How to detect the end of work through the postExecute() method

We will start with how to extend AsyncTask as it uses generics and is worth spending a few minutes on.

GettingPpast the Generics in AsyncTask

The AsyncTask class employs generics to provide type safety to its methods. AsyncTask (through generics) wants you to specify the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required