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(); } });

How do I recover the “text” from the page originating the alert, esp **after** the human user has *clicked* [dismiss] on the page’s **alert**?

I have been struggling with this issue off and on for a long time; your comment on your question solved the problem for me: After both UnexpectedAlertPresentException and NoAlertPresentException are thrown… browser.execute_script(‘alert(“Clearing out past dialogs.”)’) browser.switch_to.alert.accept() As you said in your answer, webdriver is creating a ‘dialog’ when the alert is present. Closing the alert … Read more

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

How to view remove subview?

To do what you ask you could have the overlay view as an optional, class level property, and try to remove it when the view appears class VC1: UIViewController { var overlayView: UIView? override func viewDidAppear() { super.viewDidAppear() overlayView?.removeFromSuperView() } Or you could use a protocol / delegate pattern to inform VC1 that VC2 was … Read more