what is AsyncTask in Android?
AsyncTask -> an alternate aproach for using thread and handler togather
It provides methods that replaces behaviour of thread and handler classes.
The important method in AsyncTask class are
1) doInBackground( input )- it is alternate to run() method of thread. but also has input type and return type.
2)publishProgress( input )-> it is used as alternate to sendMessage() method of handler. But it can take any data type as input.
3)onProgressUpdate(input) ->this method replace handleMessage() method of Handler.
4)onPostExecute(input) -> recieves whatever is return from doInBackground() as a final value.
5) onPreExecute()-> it executes just before doInBackground(). and used for any initialization
AsyncTask requires Types to be declared for Input data, intermediate data and final return type of doInBackground();
It provides methods that replaces behaviour of thread and handler classes.
The important method in AsyncTask class are
1) doInBackground( input )- it is alternate to run() method of thread. but also has input type and return type.
2)publishProgress( input )-> it is used as alternate to sendMessage() method of handler. But it can take any data type as input.
3)onProgressUpdate(input) ->this method replace handleMessage() method of Handler.
4)onPostExecute(input) -> recieves whatever is return from doInBackground() as a final value.
5) onPreExecute()-> it executes just before doInBackground(). and used for any initialization
AsyncTask requires Types to be declared for Input data, intermediate data and final return type of doInBackground();
Comments
Post a Comment