Make Activity.removeDialog() less strict.

It was extremely annoying not being able to do this.

Change-Id: I9a13b4fdd984a5e9d8f9ac49c7ede218c4481c2b
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 2c4babb..78a77eb 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2609,6 +2609,10 @@
      * <p>This can be useful if you know that you will never show a dialog again and
      * want to avoid the overhead of saving and restoring it in the future.
      *
+     * <p>As of {@link android.os.Build.VERSION_CODES#GINGERBREAD}, this function
+     * will not throw an exception if you try to remove an ID that does not
+     * currently have an associated dialog.</p>
+     * 
      * @param id The id of the managed dialog.
      *
      * @see #onCreateDialog(int, Bundle)
@@ -2617,17 +2621,13 @@
      * @see #dismissDialog(int)
      */
     public final void removeDialog(int id) {
-        if (mManagedDialogs == null) {
-            return;
+        if (mManagedDialogs != null) {
+            final ManagedDialog md = mManagedDialogs.get(id);
+            if (md != null) {
+                md.mDialog.dismiss();
+                mManagedDialogs.remove(id);
+            }
         }
-
-        final ManagedDialog md = mManagedDialogs.get(id);
-        if (md == null) {
-            return;
-        }
-
-        md.mDialog.dismiss();
-        mManagedDialogs.remove(id);
     }
 
     /**