Android AlertDialog dialog box cannot block the process

Because the AlertDialog dialog box cannot block the current process, if there is code to continue running or code to switch interfaces after the dialog box, the dialog box will flash by without waiting for the user to make a selection.

The correct approach should be:

if (condition) {

        AlertDialog

}else{

        Other statements

}

Reference: The use of Dialog in Android_android dialog blocking_Stop Zhutou's Blog-CSDN Blog

Guess you like

Origin blog.csdn.net/anfenggang/article/details/131428876