Could someone please help me here? : I am new to android and doing some basic activities on android studio. I have the following code which will redirect from LoginActivity to Navigation activity after successful login.

**LoginActivity.java code below:-**

    if (cancel) {
        // There was an error; don't attempt login and focus the first
        // form field with an error.
        focusView.requestFocus();
    } else {
        // Show a progress spinner, and kick off a background task to
        // perform the user login attempt.
        showProgress(true);
        mAuthTask = new UserLoginTask(email, password);

        mAuthTask.execute((Void) null);
       
        if(loginPassed) {
            Intent intent = new Intent(this, com.example.jjefry.myapplication.NavigationActivity.class);
            intent.putExtra(EXTRA_MESSAGE, "Jefry");
            startActivity(intent);
        }
    }

***loginPassed*** variable is set to true if the credentials are correct else it will be false.

If I remove ***if*** condition in the above program if will redirect to NavigationActivity properly but with ***if*** condition in place, it will simple close the application.

Not sure where am I going wrong, please help me with this.