Looper.loop() - Understanding Android's Message Queue
summary
Explains how Android really calls app code: the system boots a zygote forked process, ActivityThread runs a main Looper.loop that processes one message at a time, and handlers post messages into that queue. Shows that a fresh project generates 87 files, that configuration-change relaunch (message 126) runs teardown and onRetainCustomNonConfigurationInstance and creation in the same message (so posted results aren’t lost), demos setMessageLogging, recommends custom message queues over blind handler.post and to keep work off the main thread.
AI-written summary · about
chapters (9)
- 0:00Introduction to Looper
- 4:58Zygote and Activity Thread
- 7:47Looper.loop() Explained
- 13:28Handling Configuration Changes
- 19:54Thread Safety with Handlers
- 22:46Choreographer and Frame Updates
- 25:35Native Message Queue
- 27:01Main Thread Optimization Tips
- 28:28Q&A and Resources
related talks
23mUnderstanding the main thread
28mInside Android asynchronous processing: Understanding the Event Loop
30mExtra! Extra! Thread all about it!
30mExtra! Extra! Thread all about it!
33mUntangle your App: Efficient Threading in Android
36mDrawn out: How Android renders
42mAndroid Internals for Developers
49mWhat Mom Never Told You About Multi-Threading
