In this video we discuss about the concept of message queue and how looper and handler are used with the message queue to update the UI from another thread. To get the background as to why we need to use looper and handler you can watch another video that explains the concept of looper and handler.
Follow me on Twitter: https://twitter.com/anilvdeshpande
Link to previous video: https://www.youtube.com/watch?v=kpFwxJFYnOo
source
Github link to source code: https://github.com/AnilDeshpande/UIThreadDemo/tree/handler-code
Explained very well
in the first example how is the new thread able to verify the value of mstoploop variable wasnt it created in the original/main thread
Excellent way of explanation sir… I am learning so many things from Your videos . Thank you sir
Excellent explanation! Thanks!
Excellent explanation about looper, handler and how it works.
excellent explanation, but the audio is not good, the volume is low sometimes.
thank you
very clear explanation. thank you.
i am making a notes of the concepts which u teach, if see the notes even after few months i can get the concept clearly.
This guy is a fucking god, no joke!
Nice explanation and demo.
Sir I am not getting any exception
Nice video keep posting
Thank you . Your tutorials are too good in understand
At 1:55 Iam not getting any error. UI is updating the thread count without Handler. But for you its giving Fatal Exception. Can you explain?
Hi sir, I would like to correct you on this. The handler actually automatically has the reference to the message queue of the thread that is creating it. So here you are creating the handler on the UI thread, so it has the reference of UI thread's message queue. Hence you do not need to pass the main looper to it. Handler handler = new Handler(getApplicationContext().getMainLooper()) can be just written as Handler handler = new Handler();
Thanks for breaking this complex thing in simple words. Really appreciate your efforts in bringing these concepts to the beginners.
Simple and great video, thanks!
nice explanation . Thank you
Thanks!!
thank you.
Keep up the good work . One of the best classes I've seen on the topic
Sir could you please tell me is there any alternative to animate an object when animation is off from setting (developer option)
Thanks Codetutor this videos explained about android main threads that i didn't know until today.
Awesome
Excellent explanation sir…Keep making more videos. Thank you.
1:44 demo of crashing app when updating main thread from separate thread
2:35 Message Queue is Queue of Tasks
3:19 Looper
3:54 Handler
4:28 Demo of Looper and Handler
5:44 another simpler way of updating UI thread from separate thread
5:55 textViewThreadCount.post(new Runnable() {
@override
public void run () {
textViewThreadCount.setText(..)
}
});
Excellent video
Amazing explanation
In ui thread if want to perform some action on button click that will also add in message queue?
Voice not clear
Nice!
Seems some very useful core concept for advanced development
I think He is a Good Shepherd for Basic Android Programmers
voice not clear sometimes various please solve this issues
Hi,
Will UI Thread also placed in Message Queue?
Sir we can also use this :
runOnUiThread(new Runnable() {
@Override
public void run() {
// Our update task.
}
});
Thanks for sharing the github helpful , Can you make a video on jobscheduler with example.
Too Good.
Very good explanation. I have one doubt. what is the difference between
handler=new Handler(getApplicationContext().getMainLooper()); and handler=new Handler();
thanks , that's awesome explanation
This is the best explanation found so far. Thanks for your efforts.
Please make videos on Adapter
@Codetutor I spent so much time on these topics to understand, but now I came to a conclusion that I should have watched your videos before. It saved a lot of time.
One thing about code, you don't have to instantiate your Handler using getMainLooper() method. You could have just used Handler() with no arguments as long as you are instantiating it in the UI thread. getMainLooper() is only needed if you instantiate Handler from a non UI thread.
runOnUIthread() is good idea or not?
keep it up, good explanation
Thank you sir. Awesome way of teaching.