How to know if a dialog is dismissed in Android?

You can use an onDismissListener http://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html public Dialog createDialog() { Dialog d = new Dialog(this); d.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(final DialogInterface arg0) { // do something } }); return d; } If you are using a DialogFragment just override onDismiss() http://developer.android.com/reference/android/app/DialogFragment.html#onDismiss(android.content.DialogInterface)

How to dismiss AlertDialog.Builder?

What didn’t work about dismiss()? You should be able to use either Dialog.dismiss(), or Dialog.cancel() alertDialog.setNeutralButton(“Cancel”, new DialogInterface.OnClickListener() { // define the ‘Cancel’ button public void onClick(DialogInterface dialog, int which) { //Either of the following two lines should work. dialog.cancel(); //dialog.dismiss(); } });

How to dismiss AlertDialog in android

Actually there is no any cancel() or dismiss() method from AlertDialog.Builder Class. So Instead of AlertDialog.Builder optionDialog use AlertDialog instance. Like, AlertDialog optionDialog = new AlertDialog.Builder(this).create(); Now, Just call optionDialog.dismiss(); background.setOnClickListener(new OnClickListener() { public void onClick(View v) { SetBackground(); // here I want to dismiss it after SetBackground() method optionDialog.dismiss(); } });

Receive result from DialogFragment

Use myDialogFragment.setTargetFragment(this, MY_REQUEST_CODE) from the place where you show the dialog, and then when your dialog is finished, from it you can call getTargetFragment().onActivityResult(getTargetRequestCode(), …), and implement onActivityResult() in the containing fragment. It seems like an abuse of onActivityResult(), especially as it doesn’t involve activities at all. But I’ve seen it recommended by official google … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)