Check status of dialog in android
<p>I create dialog by:</p>

<pre><code>protected void showAlertDialog(String title, String message) {
    AlertDialog.Builder builder = new Builder(this);
    if(title != null) {
        builder.setTitle(title);
    }
    if(message != null) {
        builder.setMessage(message);
    }
    builder.setPositiveButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            backToMainActivity();
        }
    });
    builder.show();
}
</code></pre>

<p>and after that I use it in my activity. How can I check status my dialog. I mean I want to check when dialog was canceled or closed. This is any way to do that? I have a example when user click backbutton and dialog was closed and I want finish activity when dialog was closed. This is any way to check if dialog is showing or was closed?</p>
