Download the New LearnVern Android App and enter Lucky Draw to win Free Certificate
In this Video tutorial we will see most useful concept with example in Android About Async Task
It is a very useful concept and the Android application runs on a single thread when launched.
Due to this single thread model, tasks that take a long time to fetch the response can make the application non-responsive.
To avoid this kind of particular situation, we use Async task in android to perform the heavy tasks in the background on a dedicated thread and passing the results back to the UI thread.
Do In Background(): This method contains the code which needs to be executed in the background. In this method, we can send we can send requests multiple times to the UI thread by publishProgress() method. To notify that the background processing has been completed we just have to use the return statements.
On Pre Execute(): This method contains the code which is executed before the background processing starts.
On Post Execute(): This method is called after doinBackground method completes processing. The result from doinBackground is passed to this method.
onProgressUpdate(): This method receives progress updates from doInBackground method, which is published via publishProgress method, and this method can use this progress update to update the UI thread.
Have a friend to whom you would want to share this course?