Why does this NOT cause crash? I am updating UI from other thread
android, dialog, thread-safety
Solution
the dismiss() method can be run safetly on any thread as described in the Android documentation.
public void dismiss ()
Since: API Level 1 Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when the dialog is dismissed, instead implement that in onStop().
Problem
This example is copied from a book on Android. As you can see from my question, I am new to Android and trying to understand. This application should crash but it does not (I am updating UI from another thread. Which is not allowed.It should cause a crash. It does not. Why?). My code is: ``` final ProgressDialog dialogue = ProgressDialog.show(this, "title", "message"); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub try { Thread.sleep(7000); dialogue.dismiss(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); ``` This is done in `OnCreate` function. I am confused with line - `dialogue.dismiss();` Isn't that updating UI (dismissing dialogue) from another thread? Why does this app not cause segmentation fault? Thanks.