1
try{
URL urlConection = new URL(caminho);
conn = (HttpURLConnection) urlConection.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
/* DataOutputStream pt = new DataOutputStream(conn.getOutputStream());
pt.writeBytes(obj.toString());*/
PrintStream ps = new PrintStream(conn.getOutputStream());
ps.printf("json", obj.toString());
conn.connect();
//String resposta = decodifica(new String[]{new Scanner(conn.getInputStream()).next()});
String resposta = new Scanner(conn.getInputStream()).next();
Log.d("teste", obj.toString());
if(resposta.equals("1")){
Intent abreHome = new Intent(Login.this, Home.class);
startActivity(abreHome);
} else {
Toast.makeText(Login.this, "Ops houve um erro. Tente novamente", Toast.LENGTH_SHORT).show();
Log.d("retorno", resposta);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
See if it’s this or this looking for.
– ramaral
You can show an example of this JSON?
– Thiago Luiz Domacoski
My return from php webservice is an encode_json the returned data is: {"User":{"id":"1","status_id":"1","name":"Felipe Botelho","RA":"242252014","email":"[email protected]","password":"123456","data_cancel":null},"Status":{"id":"1","name":"Active"}}
– Felipe