Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Duvida Webservice GET

Eu que não achei ou tu não mandou o if onde tá dando problema?

Da algum erro no log?

Em 02/10/2014 12:33, "Alessandro Bueno" <bedinformatica@gmail.com> escreveu:
Olá amigos, sou novo no grupo e tbm no desenvolvimento android. 

Estou fazendo um app e faço uma solicitação via webservice que me retorna 0 ou 1 se tiver errado ou certo, até ai tudo blz esta funcionando. Porem minha duvida esta que não estou conseguindo usar esse resultado para tratar um if no meu app. 

Vou colocar o codigo como estou fazendo abaixo se alguem puder me dar um help! ;)

O valor esta recebendo pois eu consigo visualizar em um Log.


public void onClick(View arg0) {

AsyncTask<Void, Void, String> tarefa;

tarefa = new AsyncTask<Void, Void, String> () {

@Override

protected String doInBackground(Void... params) {

Http req = new Http();

try{

String resultado = req.doGet("http://www.revistagamemais.com.br/app_venturini/autentica_usuarios.php?login=admin&senha=1243");

//String fim = "1";

Log.d("<<< ID >>>",""+resultado);

return resultado;

} catch (IOException e) {

e.printStackTrace();

}

return null;

}

@Override

protected void onPostExecute(String result) {

// TODO Auto-generated method stub

super.onPostExecute(result);

try{

String codigo = String.valueOf(result);

//int codigo = Integer.parseInt(result);

if(codigo == "0"){

Toast.makeText(getActivity(), "Usuario não existe", Toast.LENGTH_SHORT).show();

}else{

Intent chamada = new Intent(getActivity(),PostoActivity.class);

startActivity(chamada);

}

}catch(Exception e){

Toast.makeText(getActivity(), "Servidor com Problemas", Toast.LENGTH_SHORT).show();

}

}

};

tarefa.execute(new Void[0]);

}

}


Obrigado a todos!

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário