-1
I need to make a call to Webservice on Android, and with another class call it. At the end show on design the answer obtained by Ws. I already made the Webservice only that the part of "asynchronous" is not giving.
This is my Webservice, 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 side of "Android Activity" I call this class asynchronous 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 it is not actually making an asynchronous call and the results are almost always not received by Webservice.
Is there any simpler way to do this or am I doing it wrong somewhere like the Webservice call or the Webservice class itself?
A good example to start this one. http://programmerguru.com/android-tutorial/android-restful-webservice-tutorial-part-1/
– Reginaldo Rigo
The answer is passed to the method
onPostExecute()
through the parameterresult
. It is in this method that you must treat the answer.– ramaral
You are doing nothing in the code above, you have deleted the code on
doInBackground
? As it stands, you just display a dialog and close– Lucas Queiroz Ribeiro