Skip to content

Instantly share code, notes, and snippets.

Last active June 29, 2018 22:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save getsadzeg/d5759333157c050aa3a891356b672cc9 to your computer and use it in GitHub Desktop.

AsyncTask helps us to do some heavy stuff on the thread other than UI. It allows us to do background operations and then publish to UI.

It must be subclassed and goes like this(for example):

 AsyncTask<Parameters, Progress, Result>

And it has 4 steps: onPreExecute, doInBackground, onProgressUpdate, onPostExecute.

doinBackground implementation:

public resultType doInBackground(ParamType... params) { .. }


public void onPostExecute(ResultType result) { .. }


public void onProgressUpdate(Progress... progress)

And to execute our AsyncTask class, we should do it like this:

new SomeAsyncTask().execute(parameters);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment