Android: Intent Flag to destroy activity and start new one

人盡茶涼 提交于 2019-12-03 04:47:58
Jack K Fouani

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("");

If you are supporting only API levels 11+, you should be able to use FLAG_ACTIVITY_CLEAR_TASK. This will finish all existing Activities in all tasks and create a new instance of the Login activity.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!