diff options
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 3 | ||||
| -rw-r--r-- | core/java/android/app/Dialog.java | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index ac3ca55922f6..5dc29a9d157a 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -91,7 +91,8 @@ public class AlertDialog extends Dialog implements DialogInterface { final float x = ev.getX(); final float y = ev.getY(); - if (mCancelable && (x < 0 || x > width || y < 0 || y > height)) { + if (mCancelable && (x < 0 || x > width || y < 0 || y > height) + && mDecor != null && isShowing()) { cancel(); return true; } diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index f90fc59a33b3..c398e98c5423 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -582,7 +582,7 @@ public class Dialog implements DialogInterface, Window.Callback, */ public boolean onTouchEvent(MotionEvent event) { if (mCancelable && mCanceledOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN - && isOutOfBounds(event)) { + && isOutOfBounds(event) && mDecor != null && mShowing) { cancel(); return true; } @@ -998,7 +998,6 @@ public class Dialog implements DialogInterface, Window.Callback, */ public void cancel() { if (mCancelMessage != null) { - // Obtain a new message so this dialog can be re-used Message.obtain(mCancelMessage).sendToTarget(); } |