July 2018
Intermediate to advanced
266 pages
7h 11m
English
Android will throw a CalledFromWrongThreadException whenever a thread that didn't create a view hierarchy tries to update its views. In practical terms, this exception will happen whenever a thread other than the UI thread updates a view. This is because the UI thread is the only one that can create view hierarchies, so it will always be the one that can update them.
It's important to guarantee that code that will update the UI is running in the UI thread. In our example, we will update a label on the UI thread after calling a service on a background thread.
Read now
Unlock full access