I have an Android application. I'm trying to do a request to my webserver and retreive the response from the server. It seems working. Now I'm checking if the response is equal to success, The equal() function worked well for a while and seems stopped working.
How do I properly check if the output is equal to success?
This is what I have tried:
if(LOGIN_AUTH.Login(usr, pwd, token).equals("success")) {
// Server returned 'success'
toDashboard();
}else {
// Server returned something else then 'success'
Alert("Error", LOGIN_AUTH.Login(usr, pwd, token));
alert.dismiss();
EditText password = (EditText) findViewById(R.id.login_ip_password);
assert password != null;
password.setText("");
}
I also added .trim() as I found this question: Android string .equals method not working. I tried that solution, but it's not working for me.
In the Login() function also trimmed the output like this:
return postResponse.trim().toString();
For some reason the application skipped the check and triggers the Alert() function. This alert showed me that the server returned success and there were no whitespaces, special characters or line-breaks found in the output.

LOGIN_AUTH.Login(usr, pwd, token)is not returning what you think it isLogin()twice. It may happen that the server output changed the second time. Try storing the return value in a string and debug the value.String txt = LOGIN_AUTH.Login(usr, pwd, token);and than usetxt.equals("success")?