I am trying to make a login screen for my android app. I enter to correct username and password and I get the toast message saying I have the wrong username or password. I've tried everything I can think of to try and fix this and thought I would ask for some help on here.

public void welcomeScreen(View view){
        String userName1 = "student";
        String password1 = "school";
        Intent intent = new Intent(this, WelcomeScreen.class);
        EditText editText1 = (EditText) findViewById(R.id.editText1);
        String userName = editText1.getText().toString();

        EditText editText2 = (EditText) findViewById(R.id.editText2);
        String password = editText2.getText().toString();

        if(userName != userName1 || password != password1){
            Context context = getApplicationContext();
            CharSequence text = "Incorrect Username or Password!";
            int duration = Toast.LENGTH_SHORT;

            Toast toast = Toast.makeText(context, text, duration);

        else startActivity(intent);

Guess you already solve it since post is marked as solved, but for others never do compare strings as numeric values with == or != always use strin1.equals(string2)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.