Alguém poderia me ajudar, pq não está lendo o retorno do Post, já fiz vários teste com Breakpoint
essas duas linhas em negritos.
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
private void GetText() throws UnsupportedEncodingException, JSONException {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
JSONObject jsonParam = new JSONObject();
String loginE = Login.getText().toString();
String senhaE = Senha.getText().toString();
String filialE = Filial.getText().toString();
//atribuir retorno de textview a uma string
jsonParam.put("login", (loginE));
jsonParam.put("senha", (senhaE));
jsonParam.put("filial", (filialE));
String text = "";
BufferedReader reader=null;
// Send data
try
{
// Defined URL where to send data
URL url = new URL("http://AAA.AAA.AAA.AAA:XXXX/masterlink_android/webresources/android_masterlink/Login");
// Send POST data request
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(jsonParam.toString());
wr.flush();
// Get the server response
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while((line = reader.readLine()) != null)
{
// Append server response in string
sb.append(line + "\n");
}
text = sb.toString();
}
catch(Exception ex)
{
}
finally
{
try
{
reader.close();
}
catch(Exception ex) {}
}
if (text.equals("true")) {
Toast.makeText(Login.this, "SEJA BEM VINDO", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, TelaDistribuicao.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
} else {
Toast.makeText(Login.this, "DADOS INCORRETO, TENTE NOVAMENTE", Toast.LENGTH_LONG).show();
}
}