Doubt with Dialog

1

I am using Dialog to display some information in my APP, I would like to know if there is any function for me to check if the dialog is already open so it will not open again.

 public void Dialogo_Iluminacao() {


    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dialogo_iluminacao);

    dialog.setTitle("Iluminação");

    final Switch garagem = (Switch) dialog.findViewById(R.id.switchGaragem);


    garagem.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {


    });


    dialog.show();
}

I have a function that whenever something arrives in it should show this dialog and often arrives several and would like the dialog to initialize only once

    
asked by anonymous 03.03.2015 / 12:49

2 answers

1

You can check with the isShowing() method (be sure to check if it is null, just as a precaution):

if (mDialog != null  && mDialog.isShowing()){
    //suas implementações
}

Reference: link

    
03.03.2015 / 15:06
0

Only call method:

 dialog.isShowing()

link

    
03.03.2015 / 14:55