Table of Contents

Android - AsyncTask

About

The class AsyncTask simplify background thread creation.

It's then not the best pattern for a very long background operation. See Android - Service (background operation without UI interaction)

Disadvantage

Note that when you start an AsyncTask, it is tied to the activity you start it in. When the activity is destroyed (which happens whenever the phone is rotated), the AsyncTask you started will refer to the destroyed activity and not the newly created activity. This is one of the reasons why

using AsyncTask for a longer running task is dangerous.

See loaders instead

Implementation

There are four important methods to override: