我是android新手。我只希望当我注销该应用程序时,会话不应该清除,而当同一用户再次登录时,它应该显示其用户名(从会话中获取),并要求输入密码。预先感谢。
`if(id == R.id.nav_logout){
builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle("Logout Confirmation");
builder.setMessage("Do you want to logout ?");
builder.setIcon(R.drawable.ic_exit_to_app_black_24dp);
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
UserSessionManager sessionManager = new UserSessionManager(MainActivity.this);
sessionManager.setIsLogin(false);
Intent intent = new Intent(MainActivity.this, Login.class);
startActivity(intent);
finish();
}
});
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.parseColor("#CC0809"));
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.parseColor("#CC0809"));
}`