How to close a Dialog in Android programmatically?

android, android-alertdialog, dialog, java

Solution

You can call `dismiss` on the dialog.

Problem

How do I close a Dialog in android programmatically for example by a button? Imagine I have a Dialog with a OK button on it, and want to close it by OK button, but I cant do that! I googled and found nothing useful, and almost all of them for closing AlertDialog not a Dialog.

Original source