mardi 24 avril 2018

Android if statement is NEVER exectued

Please help this is now driving me crazy. I have an if, else if and else statement inside a try block.

    if (loginSuccess.equalsIgnoreCase("true")) {
                        emailAddressEditText.setText("");
                        passwordEditText.setText("");

                        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
                        SharedPreferences.Editor editor = preferences.edit();
                        editor.putString("redirectURL", redirectUrl);
                        editor.apply();

                        Intent intent = new Intent(LoginActivity.this, WebviewActivity.class);
                        intent.putExtra("url", redirectUrl);
                        startActivity(intent);
                    } else if (loginSuccess.equalsIgnoreCase("false")) {
                        Intent intent = new Intent(LoginActivity.this, ErrorActivity.class);
                        intent.putExtra("errormessage", "loginerror");
                        startActivity(intent);
                    } else if (loginSuccess.equalsIgnoreCase("")){
                        Intent intent = new Intent(LoginActivity.this, ErrorActivity.class);
                        intent.putExtra("errormessage", "servererror");
                        startActivity(intent);
                    }

the first "if" statement never gets executed. I even tried to create a new String with "true" in it but no success. Even the log says that the loginSuccess String IS TRUE!

I/System.out: true

What is wrong?

Aucun commentaire:

Enregistrer un commentaire