consider that you are responding to a menu item


public class SomeActivity
extends Activity
{
//..other code

//a menu function
void respondToMenu1()
{
    //Say that I am going to do something a bit long
    //Show a progress dialog 
    ProgressDialog pd = new ProgressDialog(.....);
    pd.show();
    
    //do something that takes a few seconds
    doSomething();
    
    //Close the dialog to indicate we are done
    pd.dismiss();
}

//..other code
} //end of class

What is wrong with this code? How can you correct it? Are there multiple approaches? which is a preferred approach?