I was trying to understand the threading in android. As we know, we can't update a view from background thread. I was trying to understand with different cases and came across a case below. When I clicked on the Start work button, I created a thread and after 5 sec I changed the textview value from that thread. Why is it working fine and app not crashing as I am updating a view from another thread not UI thread? Can anyone explain it?
-----------------------------ds
The app works because you are updating it from the same context (same memory space). If you had a service which would directly interact "somehow" with your visible app content, for example by passing the app context to the service, then it would crash. For example, you can't use a Toast message from within a service, because the context of the service, even by using getApplicationContext(), represents the operating system and not your app. You may however use a notification, because notifications are reachable from the OS.