Hey try the following code it may helpful :
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
new TheTask().execute();
 }
private class TheTask extends AsyncTask<Void, Void, Void>{
 @Override
protected void onPreExecute()
{
    super.onPreExecute();
    pDialog = new ProgressDialog(YOUR_ACTIVITY_CLASS_NAME.this);
    pDialog.setMessage("Please Wait");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
    authenticate(); // method that calls the API via SOAP
    authenticateReal(); // method that handles the response
    return null;
}
@Override
 protected void onPostExecute(String str)
 {
    // Dismiss the dialog once finished
    pDialog.dismiss();  
  }
 }
Define pDialog before you call it:
   ProgresDialog pDialog;