0

I am trying to make an android app. But I got a problem. Every time I log in I want to login like manager or user. I got 1 table in my database for all users. But I want it to be so when I login with the user called "manager" he will see a different screen from all the other users in the table.

           ParseUser.logInInBackground(username, password, new LogInCallback() {
                @Override
                public void done(ParseUser parseUser, ParseException e) {

                    if (username == "manager") {

                        Intent takeUserHome = new Intent(LoginActivity.this, ManagerHomePage.class);
                        startActivity(takeUserHome);

                    } else {
                        Intent takeUserHome = new Intent(LoginActivity.this, UserHomePage.class);
                        startActivity(takeUserHome);

                    }

This is mine current code, but when I login with manager I still get to UserHomePage instead of the ManagerHomePage

tortuga
  • 17
  • 3

1 Answers1

0

you are comparing the string references instead on their values. using the == operator as you do in the line

username == "manager"

This compares the references, not the actual string content. what you probably want is :

username.equals("manager")

For a more in depth explenation see: this question.

Community
  • 1
  • 1
Oren
  • 4,152
  • 3
  • 30
  • 37