```
    public class myActivity extends Activity
    {
            private static AlertDialog somedialog = null;

            protected void onCreate(Bundle savedInstanceState)
            {
              somedialog = new AlertDialog.Builder(ctx).create();
              innerclass = new innerclass();
              innerclass.start();
            }
            private class innerClass extends Thread
            {
               if (!somedialog.isShowing())
               {
                             runOnUiThread(new Runnable()
                             {
                                  somedialog.setMessage("test");
                                  somedialog.show();
                             }
                }
            }

    }

```

I have this code where I have a dialog which needs to show only if the dialog is not already there. The dialog is only shown by the innerClass. There is no other method which invokes this somedialog object.

I expect the dialog to appear for the first time and to reappear only if the previous dialog has been closed, however I find there are multiple dialogs stacked on.

For some reason the isShowing method is returning false even if the dialog is open.

Any ideas as to why this is happening?

However when this code is executed somedialog.isShowing() is always returning false and hence I get multiple dialogs on top of each other.