What is AsyncTask?
AsyncTask is an abstract class provided by Android which helps us to use the UI thread properly. This class allows us to perform long/background operations and show its result on the UI thread without having to manipulate threads.
AsyncTask has four steps:
Code performing long running operation goes in this method. When onClick method is executed on click of button, it calls execute method which accepts parameters and automatically calls doInBackground method with the parameters passed.
This method is called after doInBackground method completes processing. Result from doInBackground is passed to this method.
This method is called before doInBackground method is called.
This method is invoked by calling publishProgress anytime from doInBackground call this method.
Go through this link for example