Title: Progress dialog not displayed in android?
Tags: android;progressdialog
Question: I use the progress dialog while hitting web service and wait for response from web service ,once i got the response i dismiss the progress dialog. here is the code i use for that,
dialog= ProgressDialog.show(Settings.this, "","Synchronisation with  server...", false);
request = new SoapObject(NAMESPACE, METHOD_NAME);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
androidHttpTransport = new AndroidHttpTransport(URL);
request.addProperty("mtest","1");
envelope.setOutputSoapObject(request);
try
{
System.gc();
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
}
}
dialog.dismiss();
}
catch (Exception aE)
{
aE.printStackTrace ();;
}
but the progress is not appear, if web service connected if i send the request , the application seems to be idle and does not show any progress until it got the response , i need to show some progress.
If web service is not connected the progress is displayed , but we can`t dismiss it manually.
i need to show indication of progress while hitting web service, either as separate progress or as a part of title itself. If any one know please help me out.
Thanks.

Here is the accepted answer: Try to wrap your remote calls to a secondary thread with Handler or use a AsyncTask to do the work.
Reason is, when you do ProgressDialog.Show, it scheduled the show in next update (in UI thread), which is the same thread as you are connecting web service; Hence, it never get the chance to do so since your web service is holding the UI Thread.

Here is another answer: Many people face the this problem, even i also facing same problem. The best solution for this is to use the Async Task. Hear is a sample code for that . It may help you.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:05/13/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><progressdialog>', 'Title': 'Progress dialog not displayed in android?', 'ViewCount': 427, 'id': 5987077, 'user_AboutMe': '<p>Android &amp; iphone Developer .</p>\n', 'user_AccountId': 267556.0, 'user_DisplayName': 'Karthi', 'user_Reputation': 13336.0, 'user_Views': 806.0, 'user_id': 555806.0}}