我有一个登录/注销系统,用户通过Facebook或我们自己的mysql数据库登录。改善登录/注销系统
当用户成功登录在fullying保存:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("loggedIn", true);
editor.putString("email", EMAIL);
editor.putString("password", PASSWORD);
editor.putInt("USERID", Integer.parseInt((String) product.get("ProfileID")));
editor.commit();
然后,我有一个醒目网页,如果用户登录,检查:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean loggedin = settings.getBoolean("loggedIn", false);
if (loggedin) {
Intent intent = new Intent(this, LoggedIn.class);
startActivity(intent);
} else {
Intent intent = new Intent(this, LogIn.class);
startActivity(intent);
}
然后当用户登录出:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("loggedIn", false);
editor.putString("email", "");
editor.putString("password", "");
editor.commit();
db.clearLists();
db.clearProducts();
Intent intent = new Intent(v.getContext(), Splash.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
v.getContext().startActivity(intent);
这似乎工作正常,即用户注销并返回到登录页面a nd他们所有的数据已经从应用程序中清除。
但是,有些用户报告说,如果他们关闭应用程序并返回到它,他们实际上仍然登录。 我不能复制这个,所以想知道如果任何人有任何关于如何改善我的登录/出系统改进它并防止这种情况发生。