If you are facing any issue in playing video please use Firefox browser.
In this video tutorial, we will learn about the Handler Class in Android.
Android Handler class comes from the package android.os.Handler package and is most commonly used for multithreading in Android.
A Handler object registers itself with the thread in which it is created. It provides a channel to send data to this thread.
For example, if we are making an application that contains multiple activities, and when we run it, it will firstlmake a Main/UI thread in which all of our activities will run, as there is only one Main thread in which all the activities run, we are going to make different threads to make our application flexible.
Now if we want our sub-threads to give the response to our main thread, or to handle them, there comes the concept of 'Handler'.
We use Handler to post multiple data. When we want to communicate our main activity through UI thread, Handler is used.
When we install an application in Android then it creates a thread for that application called MAIN UI Thread.
There are following two ways in which the Android handler class is usually instantiated for supporting multi-threading :
Handler handlerobject=new Handler();
Handler handlerobject=new Handler(Runnable runnableobject,Handler.Callback callbackObject);
Have a friend to whom you would want to share this course?