diff --git a/email2/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java b/email2/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java index 24715f123..5d527a030 100644 --- a/email2/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java +++ b/email2/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java @@ -78,6 +78,7 @@ public class AccountCheckSettingsFragment extends Fragment { // Support for UI private boolean mAttached; + private boolean mPaused = false; private CheckingDialog mCheckingDialog; private MessagingException mProgressException; @@ -168,12 +169,19 @@ public class AccountCheckSettingsFragment extends Fragment { @Override public void onResume() { super.onResume(); + mPaused = false; if (mState != STATE_START) { reportProgress(mState, mProgressException); } } + @Override + public void onPause() { + super.onPause(); + mPaused = true; + } + /** * This is called when the fragment is going away. It is NOT called * when the fragment is being propagated between activity instances. @@ -181,8 +189,10 @@ public class AccountCheckSettingsFragment extends Fragment { @Override public void onDestroy() { super.onDestroy(); - Utility.cancelTaskInterrupt(mAccountCheckTask); - mAccountCheckTask = null; + if (mAccountCheckTask != null) { + Utility.cancelTaskInterrupt(mAccountCheckTask); + mAccountCheckTask = null; + } } /** @@ -206,7 +216,7 @@ public class AccountCheckSettingsFragment extends Fragment { mProgressException = ex; // If we are attached, create, recover, and/or update the dialog - if (mAttached) { + if (mAttached && !mPaused) { FragmentManager fm = getFragmentManager(); switch (newState) { @@ -731,6 +741,7 @@ public class AccountCheckSettingsFragment extends Fragment { dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.cancel_action), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onCheckingDialogCancel(); @@ -828,6 +839,7 @@ public class AccountCheckSettingsFragment extends Fragment { builder.setPositiveButton( context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onEditCertificateOk(); @@ -836,6 +848,7 @@ public class AccountCheckSettingsFragment extends Fragment { builder.setNegativeButton( context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onErrorDialogEditButton(); @@ -847,6 +860,7 @@ public class AccountCheckSettingsFragment extends Fragment { builder.setPositiveButton( context.getString(R.string.account_setup_failed_dlg_edit_details_action), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onErrorDialogEditButton(); @@ -903,6 +917,7 @@ public class AccountCheckSettingsFragment extends Fragment { .setPositiveButton( context.getString(R.string.okay_action), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onSecurityRequiredDialogResultOk(true); @@ -911,6 +926,7 @@ public class AccountCheckSettingsFragment extends Fragment { .setNegativeButton( context.getString(R.string.cancel_action), new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { dismiss(); target.onSecurityRequiredDialogResultOk(false);