you need to check if dialog isShowing or not
Dialog has an isShowing() method that should return if the dialog is currently visible.
public AlertDialog myDialog;
public void showDialog(Context context) {
if( myDialog != null && myDialog.isShowing() ) return;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Title");
builder.setMessage("Message");
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss();
}});
builder.setCancelable(false);
myDialog = builder.create();
myDialog.show();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…