Ignore framework exceptions when dismissing dialogs.
Fixes http://b/2314228
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 269e63b..cc2d840 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -255,9 +255,7 @@
super.onDestroy();
for (Dialog dialog : mManagedDialogs) {
- if (dialog.isShowing()) {
- dialog.dismiss();
- }
+ dismissDialog(dialog);
}
}
@@ -321,6 +319,20 @@
}
/**
+ * Dismiss the given {@link Dialog}.
+ */
+ static void dismissDialog(Dialog dialog) {
+ try {
+ // Only dismiss when valid reference and still showing
+ if (dialog != null && dialog.isShowing()) {
+ dialog.dismiss();
+ }
+ } catch (Exception e) {
+ Log.w(TAG, "Ignoring exception while dismissing dialog: " + e.toString());
+ }
+ }
+
+ /**
* Check if our internal {@link #mState} is valid, usually checked before
* performing user actions.
*/
@@ -695,10 +707,7 @@
Toast.makeText(context, R.string.contactSavedErrorToast, Toast.LENGTH_LONG).show();
}
- // Only dismiss when valid reference and still showing
- if (progress != null && progress.isShowing()) {
- progress.dismiss();
- }
+ dismissDialog(progress);
// Stop the service that was protecting us
context.stopService(new Intent(context, EmptyService.class));