I need to make a call to the WebService on Android, and with another class call it. At the end show in design the response obtained by ws. I've already done the WebService but that part of the "asynchronous" is not giving.
This is my WebService, you get three strings :
public class WebServiceRestFull extends AsyncTask<String, String, String>
{
protected ProgressDialog dialog;
public String wsURL;
public String wsFunction;
public String wsInput;
public int codigoHTTP;
public String mensagemHTTP;
public String strResposta;
public WebServiceRestFull(Context act)
{
dialog = new ProgressDialog(act);
}
@Override
protected void onPreExecute() {
dialog.setMessage("Aguarde por favor...");
dialog.show();
}
@Override
protected void onPostExecute(String result)
{
if (dialog.isShowing())
{
dialog.dismiss();
}
}
@Override
protected String doInBackground(String... params)
{
//chamada ao webservice e retorna uma string
//return resposta do webservice;
}
}
On the "Android Activity" side I call this asynchronous class as follows:
WebServiceRestFull web = new WebServiceRestFull(this);
web.wsURL = "http://someurl.com/rest/etc";
web.wsFunction = "login";
web.wsInput = "mike";
web.execute();
Thread.sleep(1000);
The problem is that you are not actually doing an asynchronous call and the results are almost always not received by the WebService.
Is there any simpler way to do this or am I doing wrong on some side such as calling the WebService or the WebService class itself?