I have a main view (SurfaceView) in which i open an alertDialog without buttons to show some information. So then the alertDialog is a small window above the main view.
I want to close the alertDialog when the user touch anywhere on the screen.
Until now i can close the alertDialog with the touchEvent in the alertDialog.
Is there an attribute on the alterDialog or on the surfaceView?
Can i kind of activate the touchEvent listener on the surfaceView even the alertDialog is showing?
Android 2.3.3
I found additional Information about my Task on this question: dialog dismiss. Now i set this two flags (my dialog is not modal): FLAG_NOT_TOUCH_MODAL, FLAG_WATCH_OUTSIDE_TOUCH
Unfortunately in the override of the touchevent i never receive the event MotionEvent.ACTION_OUTSIDE when touch outside the dialog.
In my Activity i do this:
alertBuilder.setView(mDialogLayout);
alertDialog = alertBuilder.create();
alertDialog.setOwnerActivity(this);
And later in a other class i do that:
alertDialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alertDialog.getWindow().getAttributes());
lp.width = (int)(oJassSurfaceView.oCanvas.getWidth() *Constants.d_FactorResizeDialogWidth);
lp.height = (int)(oJassSurfaceView.oCanvas.getHeight() *Constants.d_FactorResizeDialogHeight);
lp.x=Constants.iX_PositionDialog;
lp.y=Constants.iY_PositionDialog;
alertDialog.getWindow().setAttributes(lp);
alertDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
alertDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
where is the mistake? do i need to follow a certain order when i set the flags?