You can do that in Java coding very easily. If you have an Activity (even if it looks like a Dialog), then you should do
this.setFinishOnTouchOutside(false);
if you have used Dialog class, you should call
dialog.setFinishOnTouchOutside(false)
if you want to prevent closing it open when the background activity is clicked.