Progress dialog is not showing while calling a web service
<p>I am new to android. I want to show progress dialog when user click on login button. I tried this but the dialog is not showing</p>

<pre><code>btn_logIn.setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View view) {
         getUserCredentials();
     }
}); //end of anonymous class

private void showProgressDialog() {     
    if (dialog == null) {       
        dialog = new ProgressDialog(this);          
    }
    dialog.setMessage("Please Wait. Your authentication is in progress");
    dialog.setButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which)              
            dialog.dismiss();               
        }           
    }); //end of anonymous class        
    dialog.show();  
} //end of showProgressDialog()

private void getUserCredentials() {

    EditText txt_userName = (EditText) findViewById(R.id.txt_userName);
    String userName = txt_userName.getText().toString();

    EditText txt_password = (EditText) findViewById(R.id.txt_password);
    String password = txt_password.getText().toString();

    if (userName != null &amp;&amp; !userName.trim().equals("") &amp;&amp; password != null &amp;&amp; !password.trim().equals("")) {                   
        showProgressDialog();       
        callWebService(userName, password);         
    }
} //end of getUserCredentials()

private void callWebService(String userName, String password) {

    try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("userName", userName);
        ....            
        Object result = envelope.getResponse();             
        if (result.equals("true")) {                
            dialog.dismiss();
            Toast.makeText(this, result.toString(), Toast.LENGTH_SHORT).show();

        } else {                
            dialog.dismiss();
            Toast.makeText(this, result.toString(), Toast.LENGTH_SHORT).show();                             
        }

     } catch (SocketTimeoutException e) {            
         dialog.dismiss();
         Toast.makeText(this, "Service is not connected, Please make sure your server is running", Toast.LENGTH_LONG).show();                       
    }  catch(Exception e) {         
        e.printStackTrace();
        dialog.dismiss();
        Toast.makeText(this, "Unable to connect, please try again later. Thank you", Toast.LENGTH_LONG).show();                     
     }
} //end of callWebServide()
</code></pre>

<p>Am i doing anything wrong. When i click on login button and service is not running then it shows message that <strong>Service is not connected, Please make sure your server is running"</strong>, but the dialog isn't showing...Why? My logic is when user click on login button and fields have values then start showing progress dialog and if anything happens like when result come or server is not running or if any exception happen , then i remove the dialog and show the appropriate message, but dialog isn't showing...Why? What i am doing wrong? Please help..</p>

<p>Thanks</p>
