~/talk

Understanding the main thread

Talkat droidcon London 2022 · 2022-10-27..10-28· [android]
slides:none on file

Explains how the main thread runs an infinite Looper/MessageQueue loop and how a Handler.post enqueues runnables, then demonstrates with lifecycle logs that posts from onCreate/onStart/onResume often execute in the same runnable, that posts from onStop can run after onDestroy, and that view width/height are zero until layout finishes so ViewTreeObserver.OnGlobalLayoutListener is the right tool (not magic postDelayed). Shows LiveData.setValue/postValue differences: setValue runs immediately on main thread, postValue defers and can drop frequent updates.

AI-written summary · about

  1. 0:00Introduction and speaker
  2. 0:52What is the main thread
  3. 2:16Why single main thread
  4. 3:00Messages and message queue
  5. 4:26How looper works
  6. 6:35Using handler to post
  7. 9:30Competing tasks on main thread
  8. 10:39Life cycle callbacks order
  9. 12:33Measuring view dimensions
  10. 14:02Global layout listener
  11. 14:44LiveData behavior
  12. 17:20LiveData in onResume
  13. 18:48Post vs set on LiveData
  14. 20:32Key takeaways summary
  15. 22:12Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.