Post Safely In an Uncertain Android World

5 years ago
Anonymous $QRy-cF6bU9 2

https://medium.com/@ian.andrew.alexander/post-safely-in-an-uncertain-android-world-8c0e77fa7812

As an Android developer , every so often you will run across a postDelayed in onCreate or onResume. There are plenty of StackOverflow questions asking “why doesn’t my animation run?”. And the answer often suggests using postDelayed.

But why does postDelayed work? To understand that we need to understand Android’s internals. Android has a main thread which is used to perform updates to the UI. Any Android component runs on this thread — Activities, Broadcast receivers, Fragments, Views, etc.