I have a simple android application to access a web service. I want to show a dialog "Loading . . ." until results are loaded and dismissed after loading the results. I have used this code but this doesn’t show the loading message:
public class LoadingActivity extends Activity {
private static final String SOAP_ACTION = "http://ws.eretailer.com/";
private static final String METHOD_NAME = "dataSender";
private static final String NAMESPACE = "http://ws.eretailer.com/dataSender/";
private static final String URL = "http://175.157.128.207:8085/Eretailer/services/EretailerService?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ProgressDialog pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setMessage("Loading. . .");
pd.show();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
pd.show();
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
pd.dismiss();
String str = s.toString();
String arr1[] = str.split(" ");
TextView tv = new TextView(this);
for(int i = 0; i<arr1.length;i++){
tv.append("order ID :"+arr1[i]+"\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
How can I correct this problem ?
Hi try as following code
Resource : http://www.vogella.com/articles/AndroidPerformance/article.html