문제

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

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top