Android HttpUrlConnection readStream

0

Something incredible happens to me and I already provide everything but I could not find the result, and the worst thing is that I do not know why this happens, where the error is.

I'm working with HttpUrlConnection, everything works perfect, the only thing I can not process is the PHP response. I want to know if the processes in PHP worked or not, then I return "yes" or "no" according to the result. The answer comes to Android but there is no way to process it. I explain to you

if (responseCode == HttpURLConnection.HTTP_OK)
{
    String respuesta = readStream(urlConnection.getInputStream());
    Log.e("Server Response: ", respuesta);

With these lines what I do is, first make sure that the connection was OK, then I get in the response variable what PHP returns to me. And here is my problem. readStream has to be yes or if String, at least what I think, because I tried to change the response variable to Integer, for example, or Boolean, and it throws me error, telling me that a string was expected; which is not a problem for me, Now, I try to process the content of "answer" and do not enter any of the following. I clarify that the value is "no", I corroborate stopping the Android process before the line of the if and it tells me that the answer is a String and the value is "no".

if (respuesta == "no")
{
     Log.e("Entre: ", "Entre");
}
if (respuesta.equals("no"))
{

You do not enter any of those IFs, why? if Android tells me what answer is "no" and it's a String. I pass them as I have my PHP

if (!$resultado = $con->query($sql)) {
        $response = "no";
    }else{
        $response = "si";
    }

}else{
    $response = "no";
}
echo $response;

Before I had it with json_encode ($ response); and it did not work for me either.

I DO NOT UNDERSTAND BECAUSE IT DOES NOT ENTER THE ANDROID IF IF answer="no" and it is String

    
asked by desarrollosTELLO 08.09.2018 в 14:52
source

0 answers