In my LoginActivity I'm setting a preference to identify the user is logged in and then I switch to the WelcomeActivity.
Log.v("onPostExecute", "Login successful");
// save login session in SharedPreferences
SharedPreferences settings = getSharedPreferences("LOGIN", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("email", email);
editor.commit();
Intent welcomeIntent = new Intent(getApplicationContext(), WelcomeActivity.class);
startActivity(welcomeIntent);
In my launcher activity (RegisterActivity) I'm checking in onCreate for possible settings, so that the user is redirect automatically.
// redirect to welcomeActivity if user is logged in
SharedPreferences settings = getSharedPreferences("EMAIL", 0);
String email = settings.getString("email", "");
if (!email.isEmpty()) {
Intent welcomeIntent = new Intent(getApplicationContext(), WelcomeActivity.class);
startActivity(welcomeIntent);
}
email is always empty, so the user, who logged in before and restarted the app is not automatically redirected. Any idea why?