Question

In this activity when both password and username are correct then I have shown a toast and an intent to move to next screen after login, but only toast works, intent is not working?

btnSignIn.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
        // get The User name and Password
        String userName = editTextUserName.getText().toString();
        String password = editTextPassword.getText().toString();

        // fetch the Password form database for respective user name
        String storedPassword = loginDataBaseAdapter.getSinlgeEntry(userName);

        // check if the Stored password matches with Password entered by
        // user
        if (password.equals(storedPassword)) {
            Toast.makeText(HomeActivity.this, "Congrats: Login Successfull",
                    Toast.LENGTH_LONG).show();
            dialog.dismiss();
            Intent intent = new Intent(getApplicationContext(), ViewFolders.class);
            startActivity(intent);

        } else {
            Toast.makeText(HomeActivity.this, "User Name or Password does not match",
                    Toast.LENGTH_LONG).show();
        }
    }
});

After login it is not moving to ViewFolders.class

Was it helpful?

Solution

Use:

Intent intent=new Intent(HomeActivity.this,ViewFolders.class);
startActivity(intent);

Instead of:

Intent intent=new Intent(getApplicationContext(),ViewFolders.class);
startActivity(intent);

Beside this hope ViewFolders activity is added to manifest already

OTHER TIPS

Try below:

Intent intent=new Intent(YOUR ACTIVITY.this,ViewFolders.class);
startActivity(intent);

Try this code

Intent intent=new Intent(LoginActivity.this,ViewFolders.class); 
startActivity(intent);

and an explanation here difference and when to use getApplication(), getApplicationContext(), getBaseContext() and someClass.this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top