我有一個登錄/註銷系統,用戶通過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他們所有的數據已經從應用程序中清除。
但是,有些用戶報告說,如果他們關閉應用程序並返回到它,他們實際上仍然登錄。 我不能複製這個,所以想知道如果任何人有任何關於如何改善我的登錄/出系統改進它並防止這種情況發生。