By Jay Liang Here is another thing in android that kept me scratching my head for a day before i finally figure out how to do it properly because of the lack of documentations and books for Android development at this time. The android app that I am currently working on has a search feature which will fire a http request and shows the result in a list view. The search can be slow depending on the network speed so I wanted to put a loading dialog on the screen to indicate that the app is processing. There's a ProgressDialog class in Android's SDK, so the idea is to just first build and show a progress dialog before the search starts, and then cancel the dialog on search completion: ProgressDialog pd = ProgressDialog.show(this,"Title","Message",true, false); makeHttpRequest();pd.dismiss(); The above snippet will not work because the makeHttpRequest() method is being executed on the UI thread (Android has a similar threading model as Swing) therefore the dialog will not show on the screen until makeHttpRequest() returns. That's understandable, so how about putting the method in a background thread like this: final ProgressDialog pd = ProgressDialog.show(this,"Title","Message",true, false); new Thread(new Runnable(){public void run(){makeHttpRequest();pd.dimiss();}}).start();This works as we would expect, the progress dialog is shown and then it will disappear when makeHttpRequest() is finished. However, here's the difficult bit. The above code will cause your application to crash if the user change the phone's orientation while the progress dialog is not yet dismissed. W/dalvikvm( 292): threadid=3: thread exiting with uncaught exception(group=0x40010e28)E/AndroidRuntime( 292): Uncaught handler: thread main exiting…