android - How to Logout from the application

后端 未结 4 1416
情话喂你
情话喂你 2020-12-17 07:12

My Application have 5 activities(A1,A2,A3,A4,A5). Each activity have one text view and one button(B1,B2,B3,B4,B5). If you click on that button then goes to next activity. su

4条回答
  •  时光取名叫无心
    2020-12-17 07:14

    You can also do logout by starting the LoginActivity. Example is shown below and is for when you select the Log Out button in the menu.

     @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        switch (id) {
            case R.id.action_logout:
                LoginActivity.username.setText("");
                LoginActivity.password.setText("");
                Intent logout = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(logout);
                return true;
        }
    }
    

提交回复
热议问题