Android: Intent Flag to destroy activity and start new one

前端 未结 2 1429
耶瑟儿~
耶瑟儿~ 2021-02-07 00:55

So I have a Login Activity This Activity inflates a login.xml layout which has a USER_NAME and PASSWORD EditText Views, when I enter the Username and Password and click the Logi

2条回答
  •  死守一世寂寞
    2021-02-07 01:40

    You have 2 choices:

    1 - Kill the login activity after a successful login

    Intent loginIntent = new Intent(getActivity(), Login.class);
        loginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        getActivity().startActivity(loginIntent);
    finish();
    

    2 - Empty the values then start new activity

    edittext_username.setText("");
    edittext_password.setText("");
    

提交回复
热议问题