diff --git a/src/com/android/email/activity/Welcome.java b/src/com/android/email/activity/Welcome.java index 86d56783e..7ec685002 100644 --- a/src/com/android/email/activity/Welcome.java +++ b/src/com/android/email/activity/Welcome.java @@ -40,8 +40,14 @@ import android.os.Bundle; */ public class Welcome extends Activity { + /** + * Launch this activity. Note: It's assumed that this activity is only called as a means to + * 'reset' the UI state; Because of this, it is always launched with FLAG_ACTIVITY_CLEAR_TOP, + * which will drop any other activities on the stack (e.g. AccountFolderList or MessageList). + */ public static void actionStart(Activity fromActivity) { Intent i = new Intent(fromActivity, Welcome.class); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); fromActivity.startActivity(i); } diff --git a/src/com/android/email/activity/setup/AccountSetupNames.java b/src/com/android/email/activity/setup/AccountSetupNames.java index 55387eaab..1b148c5c6 100644 --- a/src/com/android/email/activity/setup/AccountSetupNames.java +++ b/src/com/android/email/activity/setup/AccountSetupNames.java @@ -94,10 +94,7 @@ public class AccountSetupNames extends Activity implements OnClickListener { mAccount = EmailContent.Account.restoreAccountWithId(this, accountId); // Shouldn't happen, but it could if (mAccount == null) { - // The safe thing to do here is to rewind all the way to the entry activity, - // which can handle any configuration of accounts (0, 1, or 2+) - Welcome.actionStart(this); - finish(); + onBackPressed(); return; } // Get the hostAuth for receiving @@ -153,7 +150,13 @@ public class AccountSetupNames extends Activity implements OnClickListener { if (easFlowMode) { AccountSetupBasics.actionAccountCreateFinishedEas(this); } else { - AccountSetupBasics.actionAccountCreateFinished(this, mAccount.mId); + if (mAccount != null) { + AccountSetupBasics.actionAccountCreateFinished(this, mAccount.mId); + } else { + // Safety check here; If mAccount is null (due to external issues or bugs) + // just rewind back to Welcome, which can handle any configuration of accounts + Welcome.actionStart(this); + } } finish(); }