summaryrefslogtreecommitdiff
path: root/WifiDialog/src
diff options
context:
space:
mode:
Diffstat (limited to 'WifiDialog/src')
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
index 5fa0177296..01de19e200 100644
--- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
+++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
@@ -237,13 +237,26 @@ public class WifiDialogActivity extends Activity {
protected void onStop() {
super.onStop();
unregisterReceiver(mCloseSystemDialogsReceiver);
- // Dismiss and remove any active Dialogs to prevent window leaking.
- for (int i = 0; i < mActiveDialogsPerId.size(); i++) {
- Dialog dialog = mActiveDialogsPerId.valueAt(i);
- dialog.setOnDismissListener(null);
- dialog.dismiss();
+
+ if (isChangingConfigurations()) {
+ // If we're stopping due to a configuration change, dismiss all the dialogs without
+ // removing it from mLaunchIntentsPerId to prevent window leaking. The dialogs will be
+ // recreated from mLaunchIntentsPerId in onStart().
+ for (int i = 0; i < mActiveDialogsPerId.size(); i++) {
+ Dialog dialog = mActiveDialogsPerId.valueAt(i);
+ // Set the dismiss listener to null to prevent removing the Intent from
+ // mLaunchIntentsPerId.
+ dialog.setOnDismissListener(null);
+ dialog.dismiss();
+ }
+ mActiveDialogsPerId.clear();
+ } else {
+ // If we're stopping because we're switching to a new Activity, remove and cancel all
+ // the dialogs.
+ while (mActiveDialogsPerId.size() > 0) {
+ removeIntentAndPossiblyFinish(mActiveDialogsPerId.keyAt(0));
+ }
}
- mActiveDialogsPerId.clear();
}
@Override
@@ -257,7 +270,7 @@ public class WifiDialogActivity extends Activity {
}
/**
- * Remove the Intent and corresponding dialog of the given dialogId (dismissing it if it is
+ * Remove the Intent and corresponding dialog of the given dialogId (cancelling it if it is
* showing) and finish the Activity if there are no dialogs left to show.
*/
private void removeIntentAndPossiblyFinish(int dialogId) {
@@ -265,7 +278,7 @@ public class WifiDialogActivity extends Activity {
Dialog dialog = mActiveDialogsPerId.get(dialogId);
mActiveDialogsPerId.remove(dialogId);
if (dialog != null && dialog.isShowing()) {
- dialog.dismiss();
+ dialog.cancel();
}
if (mIsVerboseLoggingEnabled) {
Log.v(TAG, "Dialog id " + dialogId + " removed.");